API
#
ChartKind: 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
#
chart.data(nextData) ⇒ Sets or updates new data and returns a new Chart instance.
Kind: instance method of Chart
Param | Type |
---|---|
nextData | Array.<Object> |
Chart
#
chart.dataTypes(nextDataTypes) ⇒ Sets or updates dataTypes and returns a new Chart instance.
Kind: instance method of Chart
Param | Type |
---|---|
nextDataTypes | DataTypes |
Chart
#
chart.mapping(nextMapping) ⇒ Sets or updates mapping and returns a new Chart instance.
Kind: instance method of Chart
Param | Type |
---|---|
nextMapping | Mapping |
Chart
#
chart.visualOptions(nextVisualOptions) ⇒ Sets or updates visual options and returns a new Chart instance.
Kind: instance method of Chart
Param | Type |
---|---|
nextVisualOptions | VisualOptions |
Chart
#
chart.styles(Object) ⇒ Sets or updates styles and returns a new Chart instance.
Kind: instance method of Chart
Param | Type |
---|---|
Object | styles |
DOMChart
#
chart.renderToDOM(node, (array|object)) ⇒ Kind: instance method of Chart
Param | Type | Description |
---|---|---|
node | Node | |
(array | object) | dataReady |
string
#
chart.renderToString(document, (array|object)) ⇒ Kind: instance method of Chart
Param | Type | Description |
---|---|---|
document | document | HTML document context (optional if window is available) |
(array | object) | dataReady |
#
DOMChartKind: 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.
#
colorPresetsColor presets objects
Kind: global constant
#
scaleTypesScale types (names)
Kind: global constant
Object
#
baseOptions : base options that are injected in all charts and extended by the visualOptions declared by the chart implementation
Kind: global constant
#
validatorsdefault validators.
Kind: global constant
function
#
getPresetScale(scaleType, domain, interpolator) ⇒ Kind: global function
Returns: function
- a d3 scale
Param | Type |
---|---|
scaleType | * |
domain | * |
interpolator | * |
Array
#
getColorDomain(colorDataset, colorDataType, scaleType) ⇒ 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 | * |
function
#
getColorScale(colorDataset, colorDataType, scaleType, interpolator, userScaleValues) ⇒ 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 | * |
DataTypes
#
inferTypes(data, parsingOptions) ⇒ 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 |
ParserResult
#
parseDataset(data, [types], [parsingOptions]) ⇒ 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 |
function
#
makeMapper(dimensions, mapping, types) ⇒ 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
#
chart(chartImplementation, [config]) ⇒ 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. |
object
| string
#
DataTypeObject : 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
object
#
AggregationdDefaultObject : 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
object
#
Dimension : 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
Array.<Dimension>#
DimensionsDefinition :An array of dimensions, used to describe dimensions of a chart
Kind: global typedef
Example
object
#
MappedConfigValue : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
aggregation | string | Array.<string> | aggregation(s) function name(s) |
object
#
MappedDimension : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
value | string | Array.<string> | the mapping value |
[config] | MappedConfigValue | the optional config |
Object.<MappedDimension>#
Mapping :Kind: global typedef
object
#
VisualOptionDefinition : 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
Object.<VisualOptionDefinition>#
VisualOptionsDefinition :Kind: global typedef
Example
Object
#
VisualOptions : Kind: global typedef
Example
function
#
MappingFunction : Kind: global typedef
Param | Type | Description |
---|---|---|
dataset | array | the input dataset |
mapping | Mapping | the mapping object |
dataTypes | DataTypes | |
dimensions | DimensionsDefinition | the chart dimensions |
function
#
RenderFunction : 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. |
object
#
ChartMetadata : 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
object
#
ChartImplementation : 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 |
object
#
RawConfig : 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 |
object
#
ParsingOptions : 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 |
object
#
ParserResult : 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 |