API

Chart#

Kind: global class

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.

ParamTypeDescription
chartImplementationChartImplementationchart implementation
dataArray.<Object>
dataTypesDataTypes
mappingMapping
visualOptionsVisualOptions
stylesObject

chart.data(nextData) ⇒ Chart#

Sets or updates new data and returns a new Chart instance.

Kind: instance method of Chart

ParamType
nextDataArray.<Object>

chart.dataTypes(nextDataTypes) ⇒ Chart#

Sets or updates dataTypes and returns a new Chart instance.

Kind: instance method of Chart

ParamType
nextDataTypesDataTypes

chart.mapping(nextMapping) ⇒ Chart#

Sets or updates mapping and returns a new Chart instance.

Kind: instance method of Chart

ParamType
nextMappingMapping

chart.visualOptions(nextVisualOptions) ⇒ Chart#

Sets or updates visual options and returns a new Chart instance.

Kind: instance method of Chart

ParamType
nextVisualOptionsVisualOptions

chart.styles(Object) ⇒ Chart#

Sets or updates styles and returns a new Chart instance.

Kind: instance method of Chart

ParamType
Objectstyles

chart.renderToDOM(node, (array|object)) ⇒ DOMChart#

Kind: instance method of Chart

ParamTypeDescription
nodeNode
(arrayobject)dataReady

chart.renderToString(document, (array|object)) ⇒ string#

Kind: instance method of Chart

ParamTypeDescription
documentdocumentHTML document context (optional if window is available)
(arrayobject)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

ParamType
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

ParamType
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

ParamType
domain*
scaleType*
interpolator*

getColorScale(colorDataset, colorDataType, scaleType, interpolator, userScaleValues) ⇒ function#

Kind: global function
Returns: function - The d3 color scale

ParamTypeDescription
colorDatasetArraythe array of values of the dataset mapped on the color dimension
colorDataType'number' | 'string' | 'date' | DataTypeObjectthe type of the
scaleTypestringthe name of the scale type used
interpolatorstringthe name of the interpolator used (must be compatible with scaleType)
userScaleValuesArray.<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.

ParamType
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

ParamType
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)

ParamTypeDescription
dataarraydata to be parsed (list of objects)
parsingOptionsparsingOptions

parseDataset(data, [types], [parsingOptions]) ⇒ ParserResult#

Dataset parser

Kind: global function
Returns: ParserResult - dataset, dataTypes, errors

ParamTypeDescription
dataarraydata to be parsed (list of objects)
[types]DataTypesoptional column types
[parsingOptions]ParsingOptionsoptional parsing options

validateMapperDefinition(dimensions)#

dimensions validator

Kind: global function

ParamType
dimensionsarray

validateMapping(mapper, mapping, types)#

mapping validator

Kind: global function

ParamTypeDescription
mapperarraydefinition
mappingobjectconfiguration
typesobjectcolumn datatypes

makeMapper(dimensions, mapping, types) ⇒ function#

mapper generator

Kind: global function
Returns: function - the mapper function

ParamTypeDescription
dimensionsarraymapper definition
mappingobjectmapping configuration
typestypescolumn types

checkPredicates(conditionObject, values)#

Helper function for checking predicates, used in getEnabledOptions

Kind: global function

ParamType
conditionObject*
values*

validateOptions(optionsConfig, optionsValues)#

options validation and deserialization

Kind: global function

ParamType
optionsConfigobject
optionsValuesobject

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

ParamTypeDescription
chartImplementationChartImplementation
[config]RawConfigConfig object.

DataTypeObject : object | string#

Kind: global typedef
Properties

NameTypeDescription
type'number' | 'string' | 'date'
[dateFormat]stringdate format for dates

Example

{ type: 'date', dateFormat: 'DD-MM-YYYY }

DataTypes : Object.<('number'|'string'|'date'|DataTypeObject)>#

Kind: global typedef
Example

{ x: 'number', y: { type: 'date', dateFormat: 'DD-MM-YYYY } }

AggregationdDefaultObject : object#

Kind: global typedef
Properties

NameTypeDescription
[date]stringdefault aggregation function for dates
[number]stringdefault aggregation function for numbers
[string]stringdefault aggregation function for strings

Example

{
number: 'sum',
string: 'csvDistinct',
date: 'csvDistinct',
}

Dimension : object#

Kind: global typedef
Properties

NameTypeDefaultDescription
idstringunique id
namestringlabel
requiredboolean
[multiple]Booleanfalsecontrols if a dimension accept a value with more than one item
[minValues]numbermin number of items required for the value of the dimension
[maxValues]numbermax number of items required for the value of the dimension
validTypesArrayvalid data types for the dimension (one or more of 'number', 'string', 'date', 'boolean')
[aggregation]Booleantrue if a dimension will be aggregated
[aggregationDefault]string | AggregationdDefaultObjectdefault for aggregation

Example

{
id: 'size',
name: 'Size',
validTypes: ['number'],
required: false,
aggregation: true,
aggregationDefault: 'sum',
}

DimensionsDefinition : Array.<Dimension>#

An array of dimensions, used to describe dimensions of a chart

Kind: global typedef
Example

[
{
id: 'steps',
name: 'Steps',
validTypes: ['number', 'date', 'string'],
required: true,
multiple: true,
minValues: 2,
},
{
id: 'size',
name: 'Size',
validTypes: ['number'],
required: false,
aggregation: true,
aggregationDefault: 'sum',
},
]

MappedConfigValue : object#

Kind: global typedef
Properties

NameTypeDescription
aggregationstring | Array.<string>aggregation(s) function name(s)

MappedDimension : object#

Kind: global typedef
Properties

NameTypeDescription
valuestring | Array.<string>the mapping value
[config]MappedConfigValuethe optional config

Mapping : Object.<MappedDimension>#

Kind: global typedef

VisualOptionDefinition : object#

Kind: global typedef
Properties

NameTypeDescription
type'number' | 'boolean' | 'text' | 'colorScale'type of option
labelstringthe option label
defaultanythe default value for the option. should match the option type
[group]stringthe name of the options panel
[disabled]objectcross-conditions disabling the option
[requiredDimensions]Array.<string>dimensions that must have a value in mapping for enabling the option
[container]stringcontainer node property reference
[containerCondition]objectconditions for applying container node property reference

Example

{
type: 'number',
label: 'Maximum radius',
default: 20,
group: 'chart',
}

Example

{
type: 'boolean',
label: 'Show legend',
default: false,
group: 'artboard',
}

VisualOptionsDefinition : Object.<VisualOptionDefinition>#

Kind: global typedef
Example

{
maxRadius: {
type: 'number',
label: 'Maximum radius',
default: 20,
group: 'chart',
},
showLegend: {
type: 'boolean',
label: 'Show legend',
default: false,
group: 'artboard',
},
legendWidth: {
type: 'number',
label: 'Legend width',
default: 200,
group: 'artboard',
disabled: {
showLegend: false,
},
container: 'width',
containerCondition: {
showLegend: true,
},
},
layout: {
type: 'text',
label: 'Layout algorythm',
group: 'chart',
options: ['Cluster Dendogram', 'Tree'],
default: 'Tree',
},
colorScale: {
type: 'colorScale',
label: 'Color scale',
dimension: 'color',
default: {
scaleType: 'ordinal',
interpolator: 'interpolateSpectral',
},
group: 'color',
}
}

VisualOptions : Object#

Kind: global typedef
Example

{ with: 100, showLegend: true }

MappingFunction : function#

Kind: global typedef

ParamTypeDescription
datasetarraythe input dataset
mappingMappingthe mapping object
dataTypesDataTypes
dimensionsDimensionsDefinitionthe chart dimensions

RenderFunction : function#

Kind: global typedef

ParamTypeDescription
nodeNodean empty DOMNode that conforms to the type exposed by the chart implementation.
dataanythe data output from the mapData function defined in the cart
visualOptionsobjectthe current values of the chart visual options
mappingobjectthe mapping from column names to chart dimensions
originalDataarraythe original tabular dataset
Objectstylescss in js styles definitions, defined by the chart itself and possibly overridden when the chart instance is created.

ChartMetadata : object#

Kind: global typedef
Properties

NameTypeDescription
idstringAn unique id for the chart
namestringThe chart name
descriptionstringThe chart description
categoriesArray.<string>The list of chart categories
iconstringurl or base64 representation of chart icon (will be used as src attribute of an <img> tag)
thumbnailstringurl or base64 representation of chart thumbnail (will be used as src attribute of an <img> tag)

Example

{
name: 'Bumpchart',
id: 'rawgraphs.bumpchart',
thumbnail: 'data:image/svg+xml;base64...',
icon: 'data:image/svg+xml;base64...',
categories: ['correlations', 'proportions'],
description:
'It allows the comparison on multiple categories over a continuous dimension and the evolution of its sorting. By default, sorting is based on the stream size.',
}

ChartImplementation : object#

Kind: global typedef
Properties

NameTypeDefaultDescription
[type]'svg' | 'canvas' | div'svg'the chart type (defaults to svg)
metadataChartMetadatathe chart metadata
renderRenderFunctionthe render function
[skipMapping]Booleanfalseif set to true will skip the mapping phase (current mapping is still passed to the render function)
mapDataMappingFunctionthe mapping function
dimensionsDimensionsDefinitionthe dimensions configuration (mapping definition)
visualOptionsVisualOptionsDefinitionthe visual options exposed by the model
[styles]Object{}css in js styles definitions

RawConfig : object#

Kind: global typedef
Properties

NameTypeDefaultDescription
dataArray.<Object>the tabular data to be represented
[dataTypes]DataTypesobject with data types annotations (column name => type name). if not passed will be inferred with the inferTypes function
mappingMappingthe 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

NameTypeDescription
strictbooleanif strict is false, a JSON parsing of the values is tried. (if strict=false: "true" -> true)
localestring
decimalstring
groupstring
numeralsArray.<string>
dateLocalestring

ParserResult : object#

Kind: global typedef
Properties

NameTypeDescription
datasetArrayparsed dataset (list of objects)
dataTypesObjectdataTypes used for parsing dataset
errorsArraylist of errors from parsing