API
Chart#
Kind: global class
- Chart
- new Chart(chartImplementation, data, dataTypes, mapping, visualOptions, styles)
- .data(nextData) ⇒
Chart - .dataTypes(nextDataTypes) ⇒
Chart - .mapping(nextMapping) ⇒
Chart - .visualOptions(nextVisualOptions) ⇒
Chart - .styles(Object) ⇒
Chart - .renderToDOM(node, (array|object)) ⇒
DOMChart - .renderToString(document, (array|object)) ⇒
string
new Chart(chartImplementation, data, dataTypes, mapping, visualOptions, styles)#
Internal class used to represent a visual model with its actual configuration of data, dataTypes, mapping, visualOptions and styles.
| Param | Type | Description |
|---|---|---|
| chartImplementation | ChartImplementation | chart implementation |
| data | Array.<Object> | |
| dataTypes | DataTypes | |
| mapping | Mapping | |
| visualOptions | VisualOptions | |
| styles | Object |
chart.data(nextData) ⇒ Chart#
Sets or updates new data and returns a new Chart instance.
Kind: instance method of Chart
| Param | Type |
|---|---|
| nextData | Array.<Object> |
chart.dataTypes(nextDataTypes) ⇒ Chart#
Sets or updates dataTypes and returns a new Chart instance.
Kind: instance method of Chart
| Param | Type |
|---|---|
| nextDataTypes | DataTypes |
chart.mapping(nextMapping) ⇒ Chart#
Sets or updates mapping and returns a new Chart instance.
Kind: instance method of Chart
| Param | Type |
|---|---|
| nextMapping | Mapping |
chart.visualOptions(nextVisualOptions) ⇒ Chart#
Sets or updates visual options and returns a new Chart instance.
Kind: instance method of Chart
| Param | Type |
|---|---|
| nextVisualOptions | VisualOptions |
chart.styles(Object) ⇒ Chart#
Sets or updates styles and returns a new Chart instance.
Kind: instance method of Chart
| Param | Type |
|---|---|
| Object | styles |
chart.renderToDOM(node, (array|object)) ⇒ DOMChart#
Kind: instance method of Chart
| Param | Type | Description |
|---|---|---|
| node | Node | |
| (array | object) | dataReady |
chart.renderToString(document, (array|object)) ⇒ string#
Kind: instance method of Chart
| Param | Type | Description |
|---|---|---|
| document | document | HTML document context (optional if window is available) |
| (array | object) | dataReady |
DOMChart#
Kind: global class
new DOMChart()#
Internal class used to represent a Chart instance rendered to a DOM node. The class has no extra methods for now, but il could be used to provide an "update" functionality in the future.
colorPresets#
Color presets objects
Kind: global constant
scaleTypes#
Scale types (names)
Kind: global constant
baseOptions : Object#
base options that are injected in all charts and extended by the visualOptions declared by the chart implementation
Kind: global constant
validators#
default validators.
Kind: global constant
getPresetScale(scaleType, domain, interpolator) ⇒ function#
Kind: global function
Returns: function - a d3 scale
| Param | Type |
|---|---|
| scaleType | * |
| domain | * |
| interpolator | * |
getColorDomain(colorDataset, colorDataType, scaleType) ⇒ Array#
Extracts the color domain, given a color dataset, a color data type and a scale type for sequential scales will return 2 points domain (min and max values) for diverging scales will have 3 points domain (min value, mid value and max value) for ordinal scales the domain consists of all unique values found in the color dataset
Kind: global function
| Param | Type |
|---|---|
| colorDataset | * |
| colorDataType | * |
| scaleType | * |
getInitialScaleValues(domain, scaleType, interpolator) ⇒ Array.<Object>#
Compute the initial ranges and domains, given a domain, a scale type and an interpolator. Used to initialize the values that can be overridden by the user
Kind: global function
| Param | Type |
|---|---|
| domain | * |
| scaleType | * |
| interpolator | * |
getColorScale(colorDataset, colorDataType, scaleType, interpolator, userScaleValues) ⇒ function#
Kind: global function
Returns: function - The d3 color scale
| Param | Type | Description |
|---|---|---|
| colorDataset | Array | the array of values of the dataset mapped on the color dimension |
| colorDataType | 'number' | 'string' | 'date' | DataTypeObject | the type of the |
| scaleType | string | the name of the scale type used |
| interpolator | string | the name of the interpolator used (must be compatible with scaleType) |
| userScaleValues | Array.<Object> | overrides of ranges/domains points provided by the user |
getDefaultColorScale(defaultColor) ⇒#
Kind: global function
Returns: A d3 scale that map any value to the default color.
| Param | Type |
|---|---|
| defaultColor | * |
getAvailableScaleTypes(colorDataType, colorDataset) ⇒ Array.<string>#
gets the array of names of available scale types, given the color data type and color dataset
Kind: global function
| Param | Type |
|---|---|
| colorDataType | * |
| colorDataset | * |
inferTypes(data, parsingOptions) ⇒ DataTypes#
Types guessing
Kind: global function
Returns: DataTypes - the types guessed (object with column names as keys and value type as value)
| Param | Type | Description |
|---|---|---|
| data | array | data to be parsed (list of objects) |
| parsingOptions | parsingOptions |
parseDataset(data, [types], [parsingOptions]) ⇒ ParserResult#
Dataset parser
Kind: global function
Returns: ParserResult - dataset, dataTypes, errors
| Param | Type | Description |
|---|---|---|
| data | array | data to be parsed (list of objects) |
| [types] | DataTypes | optional column types |
| [parsingOptions] | ParsingOptions | optional parsing options |
validateMapperDefinition(dimensions)#
dimensions validator
Kind: global function
| Param | Type |
|---|---|
| dimensions | array |
validateMapping(mapper, mapping, types)#
mapping validator
Kind: global function
| Param | Type | Description |
|---|---|---|
| mapper | array | definition |
| mapping | object | configuration |
| types | object | column datatypes |
makeMapper(dimensions, mapping, types) ⇒ function#
mapper generator
Kind: global function
Returns: function - the mapper function
| Param | Type | Description |
|---|---|---|
| dimensions | array | mapper definition |
| mapping | object | mapping configuration |
| types | types | column types |
checkPredicates(conditionObject, values)#
Helper function for checking predicates, used in getEnabledOptions
Kind: global function
| Param | Type |
|---|---|
| conditionObject | * |
| values | * |
validateOptions(optionsConfig, optionsValues)#
options validation and deserialization
Kind: global function
| Param | Type |
|---|---|
| optionsConfig | object |
| optionsValues | object |
chart(chartImplementation, [config]) ⇒ Chart#
This is the entry point for creating a chart with raw. It will return an instance of the RAWChart class
Kind: global function
| Param | Type | Description |
|---|---|---|
| chartImplementation | ChartImplementation | |
| [config] | RawConfig | Config object. |
DataTypeObject : object | string#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| type | 'number' | 'string' | 'date' | |
| [dateFormat] | string | date format for dates |
Example
DataTypes : Object.<('number'|'string'|'date'|DataTypeObject)>#
Kind: global typedef
Example
AggregationdDefaultObject : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| [date] | string | default aggregation function for dates |
| [number] | string | default aggregation function for numbers |
| [string] | string | default aggregation function for strings |
Example
Dimension : object#
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| id | string | unique id | |
| name | string | label | |
| required | boolean | ||
| [multiple] | Boolean | false | controls if a dimension accept a value with more than one item |
| [minValues] | number | min number of items required for the value of the dimension | |
| [maxValues] | number | max number of items required for the value of the dimension | |
| validTypes | Array | valid data types for the dimension (one or more of 'number', 'string', 'date', 'boolean') | |
| [aggregation] | Boolean | true if a dimension will be aggregated | |
| [aggregationDefault] | string | AggregationdDefaultObject | default for aggregation |
Example
DimensionsDefinition : Array.<Dimension>#
An array of dimensions, used to describe dimensions of a chart
Kind: global typedef
Example
MappedConfigValue : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| aggregation | string | Array.<string> | aggregation(s) function name(s) |
MappedDimension : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| value | string | Array.<string> | the mapping value |
| [config] | MappedConfigValue | the optional config |
Mapping : Object.<MappedDimension>#
Kind: global typedef
VisualOptionDefinition : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| type | 'number' | 'boolean' | 'text' | 'colorScale' | type of option |
| label | string | the option label |
| default | any | the default value for the option. should match the option type |
| [group] | string | the name of the options panel |
| [disabled] | object | cross-conditions disabling the option |
| [requiredDimensions] | Array.<string> | dimensions that must have a value in mapping for enabling the option |
| [container] | string | container node property reference |
| [containerCondition] | object | conditions for applying container node property reference |
Example
Example
VisualOptionsDefinition : Object.<VisualOptionDefinition>#
Kind: global typedef
Example
VisualOptions : Object#
Kind: global typedef
Example
MappingFunction : function#
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| dataset | array | the input dataset |
| mapping | Mapping | the mapping object |
| dataTypes | DataTypes | |
| dimensions | DimensionsDefinition | the chart dimensions |
RenderFunction : function#
Kind: global typedef
| Param | Type | Description |
|---|---|---|
| node | Node | an empty DOMNode that conforms to the type exposed by the chart implementation. |
| data | any | the data output from the mapData function defined in the cart |
| visualOptions | object | the current values of the chart visual options |
| mapping | object | the mapping from column names to chart dimensions |
| originalData | array | the original tabular dataset |
| Object | styles | css in js styles definitions, defined by the chart itself and possibly overridden when the chart instance is created. |
ChartMetadata : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| id | string | An unique id for the chart |
| name | string | The chart name |
| description | string | The chart description |
| categories | Array.<string> | The list of chart categories |
| icon | string | url or base64 representation of chart icon (will be used as src attribute of an <img> tag) |
| thumbnail | string | url or base64 representation of chart thumbnail (will be used as src attribute of an <img> tag) |
Example
ChartImplementation : object#
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| [type] | 'svg' | 'canvas' | div | 'svg' | the chart type (defaults to svg) |
| metadata | ChartMetadata | the chart metadata | |
| render | RenderFunction | the render function | |
| [skipMapping] | Boolean | false | if set to true will skip the mapping phase (current mapping is still passed to the render function) |
| mapData | MappingFunction | the mapping function | |
| dimensions | DimensionsDefinition | the dimensions configuration (mapping definition) | |
| visualOptions | VisualOptionsDefinition | the visual options exposed by the model | |
| [styles] | Object | {} | css in js styles definitions |
RawConfig : object#
Kind: global typedef
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| data | Array.<Object> | the tabular data to be represented | |
| [dataTypes] | DataTypes | object with data types annotations (column name => type name). if not passed will be inferred with the inferTypes function | |
| mapping | Mapping | the current mapping of column names to dimensions of the current visual model | |
| [visualOptions] | VisualOptions | {} | visual options values |
| [styles] | Object | {} | css in js styles definitions |
ParsingOptions : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| strict | boolean | if strict is false, a JSON parsing of the values is tried. (if strict=false: "true" -> true) |
| locale | string | |
| decimal | string | |
| group | string | |
| numerals | Array.<string> | |
| dateLocale | string |
ParserResult : object#
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| dataset | Array | parsed dataset (list of objects) |
| dataTypes | Object | dataTypes used for parsing dataset |
| errors | Array | list of errors from parsing |