picasso.js
A charting library streamlined for building visualizations for the Qlik Sense Analytics platform.
picasso.js entry point
Parameters
- cfg object
cfg properties
- renderer object
renderer properties
- prio Array< string >Required
-
- logger object
logger properties
- level 0 | 1 | 2 | 3 | 4Required
-
- style object
- palettes Array< object >
-
Returns
- Required
properties
- chart() functionRequiredParameters
- definition ChartDefinitionRequired
Returns- Required
-
- component registryRequired
Component registry
- data registryRequired
Data registry
- formatter registryRequired
Formatter registry
- interaction registryRequired
Interaction registry
- renderer registryRequired
Renderer registry
- scale registryRequired
Scale registry
- use() functionRequired
Plugin registry
Parameters- plugin pluginRequired
- options object
-
- version stringRequired
picasso.js version
-
Properties
- component registryRequired
Component registry
component properties
- registry() functionRequired
Register a
value
with the givenkey
. Ifvalue
is omitted, returns thevalue
ofkey
.Parameters- key stringRequired
Name of the type to register
- value any
Value to store in the registry.
Returns- anyRequired
Registered value
-
-
- data registryRequired
Data registry
- formatter registryRequired
Formatter registry
- interaction registryRequired
Interaction registry
- renderer registryRequired
Renderer registry
- scale registryRequired
Scale registry
- version stringRequired
picasso.js version
picassojs
import picasso from 'picasso.js';
const configuredPicasso = picasso({ renderer: { prio: ['canvas'] } }) // All components will render using the canvas renderer
Parameters
- definition ChartDefinitionRequired
definition properties
- beforeDestroy beforeDestroy
beforeDestroy properties
- beforeDestroy() functionRequired
Called before the chart has been destroyed
-
- beforeMount beforeMount
beforeMount properties
- beforeMount() functionRequired
Called before the chart has been mounted
-
- beforeRender beforeRender
beforeRender properties
- beforeRender() functionRequired
Called before the chart has been rendered
-
- beforeUpdate beforeUpdate
beforeUpdate properties
- beforeUpdate() functionRequired
Called before the chart has been updated
-
- created created
created properties
- created() functionRequired
Called when the chart has been created
-
- destroyed destroyed
destroyed properties
- destroyed() functionRequired
Called after the chart has been destroyed
-
- mounted mounted
mounted properties
- mounted() functionRequired
Called after the chart has been mounted
Parameters- element HTMLElementRequired
The element the chart been mounted to
-
-
- updated updated
updated properties
- updated() functionRequired
Called after the chart has been updated
-
- data Array< DataSource > | DataSourceRequired
Chart data
- element HTMLElementRequired
Element to attach chart to
- settings ChartSettingsRequired
Chart settings
settings properties
- components Array< ComponentTypes >
Components
- scales object
Dictionary with scale definitions
- formatters object
Dictionary with formatter definitions
- strategy DockLayoutSettings
Dock layout strategy
strategy properties
- logicalSize object
Logical size
logicalSize properties
- width number
Width in pixels
- height number
Height in pixels
- preserveAspectRatio boolean
If true, takes the smallest ratio of width/height between logical and physical size ( physical / logical )
- align number
Normalized value between 0-1. Defines how the space around the scaled axis is spread in the container, with 0.5 meaning the spread is equal on both sides. Only applicable if preserveAspectRatio is set to true
-
- center object
Define how much space the center dock area requires
center properties
- minWidthRatio number
Value between 0 and 1
- minHeightRatio number
Value between 0 and 1
- minWidth number
Width in pixels
- minHeight number
Height in pixels
-
- layoutModes object
Dictionary with named sizes
- size object
Size is equal to that of the container (element) of the chart by default. It's possible to overwrite it by explicitly setting width or height
size properties
- width number
Width in pixels
- height number
Height in pixels
-
-
- interactions Array< InteractionSettings >
Interaction handlers
- collections Array< CollectionSettings >
Collections
-
-
Returns
- Required
properties
- brush() functionRequired
Get or create brush context for this chart
Parameters- name stringRequired
Name of the brush context. If no match is found, a new brush context is created and returned.
Returns- Required
properties
- addAndRemoveValues() functionRequired
Add and remove values in a single operation almost the same as calling addValues and removeValues but only triggers one 'update' event
If the state of the brush changes, an 'update' event is emitted.
Parameters- addItems Array< object >Required
Items to add
- removeItems Array< object >Required
Items to remove
-
- addKeyAlias() functionRequired
Adds an alias to the given key
Parameters- key stringRequired
Value to be replaced
- alias stringRequired
Value to replace key with
-
- addRange() functionRequired
Adds a numeric range to this brush context
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to add to this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- addRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to remove
-
- addValue() functionRequired
Adds a primitive value to this brush context
If this brush context is not started, a 'start' event is emitted. If the state of the brush changes, ie. if the added value does not already exist, an 'update' event is emitted.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to add
-
- addValues() functionRequiredParameters
- items Array< object >Required
Items to add
-
- brushes() functionRequired
Returns all brushes within this context
Returns- objectRequired
-
- clear() functionRequired
Clears this brush context
- configure() functionRequired
Configure the brush instance.
Parameters- config BrushConfigRequired
config properties
- ranges Array< Ranges >
Range configurations
-
-
- containsRange() functionRequired
Checks if a range segment is contained within this brush context
Returns true if the range segment exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- range objectRequired
The range to check for
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Returns- booleanRequired
-
- containsRangeValue() functionRequired
Checks if a value is contained within a range in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value numberRequired
The value to check for
Returns- booleanRequired
-
- containsValue() functionRequired
Checks if a certain value exists in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to check for
Returns- booleanRequired
-
- end() functionRequired
Ends this brush context
Ends this brush context and emits an 'end' event if it is not already ended.
Parameters- args anyRequired
arguments to be passed to 'end' listeners
-
- intercept() functionRequired
Adds an event interceptor
Parameters- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to call before event is triggered
-
- isActive() functionRequired
Checks if this brush is activated
Returns true if started, false otherwise
Returns- booleanRequired
-
- link() functionRequired
Link this brush to another brush instance.
When linked, the
target
will receive updates whenever this brush changes.Parameters- target BrushRequired
The brush instance to link to
-
- removeAllInterceptors() functionRequired
Removes all interceptors
Parameters- name string
Name of the event to remove interceptors for. If not provided, removes all interceptors.
-
- removeInterceptor() functionRequired
Removes an interceptor
Parameters- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to remove
-
- removeKeyAlias() functionRequired
Removes an alias
This will only remove the key to alias mapping for new manipulations of the brush, no changes will be made to the current state of this brush.
Parameters- key stringRequired
Value to remove as alias
-
- removeRange() functionRequired
Removes a numeric range from this brush context
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to remove from this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- removeRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to remove
-
- removeValue() functionRequired
Removes a primitive values from this brush context
If the state of the brush changes, ie. if the removed value does exist, an 'update' event is emitted.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to remove
-
- removeValues() functionRequiredParameters
- items Array< object >Required
Items to remove
-
- setRange() functionRequired
Sets a numeric range to this brush context
Overwrites any active ranges identified by
key
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to set on this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- setRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to set
-
- setValues() functionRequiredParameters
- items Array< object >Required
Items to set
-
- start() functionRequired
Starts this brush context
Starts this brush context and emits a 'start' event if it is not already started.
Parameters- args anyRequired
arguments to be passed to 'start' listeners
-
- toggleRange() functionRequired
Toggles a numeric range in this brush context
Removes the range if it's already contained within the given identifier, otherwise the given range is added to the brush.
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to toggle in this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- toggleRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to toggle
-
- toggleValue() functionRequired
Toggles a primitive value in this brush context
If the given value exists in this brush context, it will be removed. If it does not exist it will be added.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to toggle
-
- toggleValues() functionRequiredParameters
- items Array< object >Required
Items to toggle
-
-
-
- brushFromShapes() functionRequired
Brush data by providing a collection of data bound shapes.
Parameters- shapes Array< SceneNode >Required
An array of data bound shapes.
- config objectRequired
Options
config properties
- components Array< BrushTargetConfig >Required
Array of components to include in the lookup
-
-
- component() functionRequired
Get a component context
Parameters- key stringRequired
Component key
Returns- Required
Component context
properties
- type stringRequired
Type of component
- key stringRequired
Key of the component
-
-
- componentsFromPoint() functionRequired
Get components overlapping a point.
Parameters- p PointRequired
Point with x- and y-coordinate. The coordinate is relative to the browser viewport.
p properties
- x numberRequired
X-coordinate
- y numberRequired
Y-coordinate
-
Returns- Array< Component >Required
Array of component contexts
-
- dataset() functionRequired
Get
Parameters- key stringRequired
Get the dataset identified by
key
Returns- Required
properties
- extract() functionRequired
Extract data items from this dataset
Parameters- config Extract | DataFieldExtractionRequired
Returns- Array< DatumExtract >Required
-
- field() functionRequired
Find a field within this dataset
Parameters- query stringRequired
The field to find
Returns- Required
properties
- formatter() functionRequired
Returns a formatter adapted to the content of this field.
- id() functionRequired
Returns this field's id
Returns- stringRequired
-
- items() functionRequired
Returns the values of this field.
Returns- Array< DatumExtract >Required
-
- key() functionRequired
Returns this field's key
Returns- stringRequired
-
- max() functionRequired
Returns the max value of this field.
Returns- numberRequired
-
- min() functionRequired
Returns the min value of this field.
Returns- numberRequired
-
- raw() functionRequired
Returns the input data
Returns- anyRequired
-
- tags() functionRequired
Returns the tags.
Returns- Array< string >Required
-
- title() functionRequired
Returns this field's title.
Returns- stringRequired
-
- type() functionRequired
Returns this field's type: 'dimension' or 'measure'.
Returns- stringRequired
-
-
-
- fields() functionRequired
Get all fields within this dataset
Returns- Array< Field >Required
-
- hierarchy() functionRequiredReturns
- nullRequired
-
- key() functionRequired
Get the key identifying this dataset
Returns- stringRequired
-
- raw() functionRequired
Get the raw data
Returns- anyRequired
-
-
-
- destroy() functionRequired
Destroy the chart instance.
- findShapes() functionRequired
Get all nodes matching the provided selector
Parameters- selector stringRequired
CSS selector [type, attribute, universal, class]
Returns- Array< SceneNode >Required
Array of objects containing matching nodes
-
- formatter() functionRequired
Get or create a formatter for this chart
Parameters- v string | objectRequired
Formatter reference or formatter options
Returns- Required
properties
- formatter() functionRequiredReturns
- anyRequired
Returns a formatted value
-
-
-
- formatters() functionRequired
Get all registered formatters
Returns- objectRequired
-
- getAffectedShapes() functionRequired
Get all shapes associated with the provided context
Parameters- context stringRequired
The brush context
- mode stringRequired
Property comparison mode.
- props Array< string >Required
Which specific data properties to compare
- key stringRequired
Which component to get shapes from. Default gives shapes from all components.
Returns- Array< object >Required
Array of objects containing shape and parent element
-
- interactions objectRequired
Get all interaction instances
interactions properties
- instances Array< Interaction >Required
- off() functionRequired
Disable all interaction instances
- on() functionRequired
Enable all interaction instances
-
- layoutComponents() functionRequiredExperimental
Layout the chart with new settings and / or data
Parameters- def object
New chart definition
def properties
- data Array< DataSource > | DataSource
Chart data
- settings ChartSettings
Chart settings
- excludeFromUpdate Array< string >
Keys of components to not include in the layout
-
-
- scale() functionRequired
Get or create a scale for this chart
Parameters- v string | objectRequired
Scale reference or scale options
Returns- Required
properties
- type stringRequired
Type of scale
-
-
- scales() functionRequired
Get all registered scales
Returns- objectRequired
-
- shapesAt() functionRequired
Get all nodes colliding with a geometrical shape (circle, line, rectangle, point, polygon, geopolygon).
The input shape is identified based on the geometrical attributes in the following order: circle => line => rectangle => point => polygon => geopolygon. Note that not all nodes on a scene have collision detection enabled.
Parameters-
A geometrical shape. Coordinates are relative to the top-left corner of the chart instance container.
- opts objectRequired
Options
opts properties
- components Array< object >
Array of components to include in the lookup. If no components are specified, all components will be included.
- propagation string
if set to
stop
, will start lookup on top visible component and propagate downwards until a component has at least a match.
-
Returns- Array< SceneNode >Required
Array of objects containing colliding nodes
-
- toggleBrushing() functionRequiredParameters
- val boolean
Toggle brushing on or off. If value is omitted, a toggle action is applied to the current state.
-
- update() functionRequired
Update the chart with new settings and / or data
Parameters- def object
New chart definition
def properties
- data Array< DataSource > | DataSource
Chart data
- settings ChartSettings
Chart settings
- partialData boolean
If set to true, will trigger a data update only. Meaning the layout will not be updated
- excludeFromUpdate Array< string >
Keys of components to not include in the update
-
-
-
chart
picasso.chart({
element: document.querySelector('#container'), // This is the element to render the chart in
data: [
{
type: 'matrix',
data: [
['Month', 'Sales', 'Margin'],
['Jan', 1106, 7],
['Feb', 5444, 53],
['Mar', 147, 64],
['Apr', 7499, 47],
['May', 430, 62],
['June', 9735, 13],
['July', 5832, 13],
['Aug', 7435, 15],
['Sep', 3467, 35],
['Oct', 3554, 78],
['Nov', 5633, 23],
['Dec', 6354, 63],
],
},
],
settings: {
scales: {
x: { data: { field: 'Margin' } },
y: { data: { field: 'Sales' } },
},
components: [
{
// specify how to render the chart
type: 'axis',
scale: 'y',
layout: {
dock: 'left',
},
},
{
type: 'axis',
scale: 'x',
layout: {
dock: 'bottom',
},
},
{
type: 'point',
data: {
extract: {
field: 'Month',
props: {
x: { field: 'Margin' },
y: { field: 'Sales' },
},
},
},
settings: {
x: { scale: 'x' },
y: { scale: 'y' },
size: function () {
return Math.random();
},
},
},
],
},
});
Plugin registry
Parameters
- plugin pluginRequired
plugin properties
- plugin() functionRequired
Callback function to register a plugin
Parameters- registries RegistriesRequired
- options objectRequired
-
-
- options object
Properties
- startAngle numberRequired
Start of arc line, in radians
- endAngle numberRequired
End of arc line, in radians
- radius numberRequired
Radius of arc line
Add and remove values in a single operation almost the same as calling addValues and removeValues but only triggers one 'update' event
If the state of the brush changes, an 'update' event is emitted.
Parameters
- addItems Array< object >Required
Items to add
- removeItems Array< object >Required
Items to remove
Adds an alias to the given key
Parameters
- key stringRequired
Value to be replaced
- alias stringRequired
Value to replace key with
addKeyAlias
brush.addKeyAlias('BadFieldName', 'Region');
brush.addValue('BadFieldName', 'Sweden'); // 'BadFieldName' will be stored as 'Region'
brush.containsValue('Region', 'Sweden'); // true
brush.containsValue('BadFieldName', 'Sweden'); // true
Adds a numeric range to this brush context
Parameters
- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to add to this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
addRange
brush.addRange('Sales', { min: 20, max: 50 });
Parameters
- items Array< object >Required
Items containing the ranges to remove
Adds a primitive value to this brush context
If this brush context is not started, a 'start' event is emitted. If the state of the brush changes, ie. if the added value does not already exist, an 'update' event is emitted.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to add
addValue
brush.addValue('countries', 'Sweden');
brush.addValue('/qHyperCube/qDimensionInfo/0', 3);
Configure the brush instance.
Parameters
- config BrushConfigRequired
config properties
- ranges Array< Ranges >
Range configurations
-
configure
brushInstance.configure({
ranges: [
{ key: 'some key', includeMax: false },
{ includeMax: true, includeMin: true },
]
})
Checks if a range segment is contained within this brush context
Returns true if the range segment exists for the provided key, returns false otherwise.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- range objectRequired
The range to check for
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Returns
- booleanRequired
containsRange
brush.addRange('Sales', { min: 10, max: 50 });
brush.containsRange('Sales', { min: 15, max: 20 }); // true - the range segment is fully contained within [10, 50]
brush.containsRange('Sales', { min: 5, max: 20 }); // false - part of the range segment is outside [10, 50]
brush.containsRange('Sales', { min: 30, max: 80 }); // false - part of the range segment is outside [10, 50]
Checks if a value is contained within a range in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- value numberRequired
The value to check for
Returns
- booleanRequired
containsRangeValue
brush.addRange('Sales', { min: 10, max: 50 });
brush.containsRangeValue('Sales', 30); // true
brush.containsRangeValue('Sales', 5); // false
Checks if a certain value exists in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to check for
Returns
- booleanRequired
containsValue
brush.addValue('countries', 'Sweden');
brush.containsValue('countries', 'Sweden'); // true
brush.toggleValue('countries', 'Sweden'); // remove 'Sweden'
brush.containsValue('countries', 'Sweden'); // false
Ends this brush context
Ends this brush context and emits an 'end' event if it is not already ended.
Parameters
- args anyRequired
arguments to be passed to 'end' listeners
Adds an event interceptor
Parameters
- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to call before event is triggered
intercept
brush.intercept('add-values', items => {
console.log('about to add the following items', items);
return items;
});
Checks if this brush is activated
Returns true if started, false otherwise
Returns
- booleanRequired
Link this brush to another brush instance.
When linked, the target
will receive updates whenever this brush changes.
Parameters
- target BrushRequired
The brush instance to link to
Removes all interceptors
Parameters
- name string
Name of the event to remove interceptors for. If not provided, removes all interceptors.
Removes an interceptor
Parameters
- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to remove
Removes an alias
This will only remove the key to alias mapping for new manipulations of the brush, no changes will be made to the current state of this brush.
Parameters
- key stringRequired
Value to remove as alias
removeKeyAlias
brush.removeKeyAlias('BadFieldName');
Removes a numeric range from this brush context
Parameters
- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to remove from this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Parameters
- items Array< object >Required
Items containing the ranges to remove
Removes a primitive values from this brush context
If the state of the brush changes, ie. if the removed value does exist, an 'update' event is emitted.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to remove
removeValue
brush.removeValue('countries', 'Sweden');
Sets a numeric range to this brush context
Overwrites any active ranges identified by key
Parameters
- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to set on this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Parameters
- items Array< object >Required
Items containing the ranges to set
Starts this brush context
Starts this brush context and emits a 'start' event if it is not already started.
Parameters
- args anyRequired
arguments to be passed to 'start' listeners
Toggles a numeric range in this brush context
Removes the range if it's already contained within the given identifier, otherwise the given range is added to the brush.
Parameters
- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to toggle in this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Parameters
- items Array< object >Required
Items containing the ranges to toggle
Toggles a primitive value in this brush context
If the given value exists in this brush context, it will be removed. If it does not exist it will be added.
Parameters
- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to toggle
toggleValue
brush.toggleValue('countries', 'Sweden');
Triggered when this brush is updated
Parameters
- added Array< object >Required
The added items
- removed Array< object >Required
The removed items
Properties
- ranges Array< Ranges >
Range configurations
Properties
- context string
Name of the brush context to observe
- data Array< string >
The mapped data properties to observe
- mode string
Data properties operator: and, or, xor.
- filter function
Filtering function
- style object
The style to apply to the shapes of the component
style properties
- active object
The style of active data points
- inactive object
The style of inactive data points
-
BrushConsumeSettings
{
context: 'selection',
data: ['x'],
filter: (shape) => shape.type === 'circle',
style: {
active: {
fill: 'red',
stroke: '#333',
strokeWidth: (shape) => shape.strokeWidth * 2,
},
inactive: {},
},
}
Properties
- key stringRequired
Component key
- contexts Array< string >
Name of the brushing contexts to affect
- data Array< string >
The mapped data properties to add to the brush
- action string
Type of action to respond with
Properties
- on string
Type of interaction to trigger brush on
- action string
Type of interaction to respond with
- contexts Array< string >
Name of the brushing contexts to affect
- data Array< string >
The mapped data properties to add to the brush
- propagation string
Control the event propagation when multiple shapes are tapped. Disabled by default
- globalPropagation string
Control the event propagation between components. Disabled by default
- touchRadius number
Extend contact area for touch events. Disabled by default
- mouseRadius number
Extend contact area for regular mouse events. Disabled by default
BrushTriggerSettings
{
on: 'tap',
action: 'toggle',
contexts: ['selection', 'tooltip'],
data: ['x'],
propagation: 'stop', // 'stop' => prevent trigger from propagating further than the first shape
globalPropagation: 'stop', // 'stop' => prevent trigger of same type to be triggered on other components
touchRadius: 24,
mouseRadius: 10
}
Create a new canvas renderer
Parameters
- sceneFn function
Scene factory
Returns
- Required
A canvas renderer instance
properties
- appendTo() functionRequiredParameters
- element HTMLElementRequired
Element to attach renderer to
Returns- HTMLElementRequired
Root element of the renderer
-
- clear() functionRequired
Clear all child elements from the renderer root element
Returns- Required
The renderer instance
-
- destory() functionRequired
Remove the renderer root element from its parent element
- element() functionRequired
Get the element this renderer is attached to
Returns- HTMLElementRequired
-
- findShapes() functionRequired
Get all nodes matching the provided selector
Parameters- selector stringRequired
CSS selector [type, attribute, universal, class]
Returns- Array< SceneNode >Required
Array of objects containing matching nodes
-
- itemsAt() functionRequired
Get nodes renderer at area
Parameters-
Get nodes that intersects with geometry
Returns- Array< SceneNode >Required
-
- measureText() functionRequiredParameters
- opts objectRequired
opts properties
- text stringRequired
Text to measure
- fontSize stringRequired
Font size
- fontFamily stringRequired
Font family
-
Returns- objectRequired
Width and height of text
-
- render() functionRequiredParameters
- nodes Array< object >Required
Nodes to render
Returns- booleanRequired
True if the nodes were rendered, otherwise false
-
- root() functionRequired
Get the root element of the renderer
Returns- HTMLElementRequired
-
- settings() functionRequired
Set or Get renderer settings
Parameters- settings object
Settings for the renderer
-
- size() functionRequired
Set or Get the size definition of the renderer container.
Parameters- opts SizeDefinition
Size definition
opts properties
- x number
x-coordinate
- y number
y-coordinate
- width number
Width
- height number
Height
- scaleRatio object
scaleRatio properties
- x number
Scale ratio on x-axis
- y number
Scale ratio on y-axis
-
- margin object
margin properties
- left number
Left margin
- top number
Top margin
-
-
Returns- Required
The current size definition
-
-
Chart instance
Properties
- interactions objectRequired
Get all interaction instances
interactions properties
- instances Array< Interaction >Required
- off() functionRequired
Disable all interaction instances
- on() functionRequired
Enable all interaction instances
-
Get or create brush context for this chart
Parameters
- name stringRequired
Name of the brush context. If no match is found, a new brush context is created and returned.
Returns
- Required
properties
- addAndRemoveValues() functionRequired
Add and remove values in a single operation almost the same as calling addValues and removeValues but only triggers one 'update' event
If the state of the brush changes, an 'update' event is emitted.
Parameters- addItems Array< object >Required
Items to add
- removeItems Array< object >Required
Items to remove
-
- addKeyAlias() functionRequired
Adds an alias to the given key
Parameters- key stringRequired
Value to be replaced
- alias stringRequired
Value to replace key with
-
- addRange() functionRequired
Adds a numeric range to this brush context
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to add to this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- addRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to remove
-
- addValue() functionRequired
Adds a primitive value to this brush context
If this brush context is not started, a 'start' event is emitted. If the state of the brush changes, ie. if the added value does not already exist, an 'update' event is emitted.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to add
-
- addValues() functionRequiredParameters
- items Array< object >Required
Items to add
-
- brushes() functionRequired
Returns all brushes within this context
Returns- objectRequired
-
- clear() functionRequired
Clears this brush context
- configure() functionRequired
Configure the brush instance.
Parameters- config BrushConfigRequired
config properties
- ranges Array< Ranges >
Range configurations
-
-
- containsRange() functionRequired
Checks if a range segment is contained within this brush context
Returns true if the range segment exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- range objectRequired
The range to check for
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
Returns- booleanRequired
-
- containsRangeValue() functionRequired
Checks if a value is contained within a range in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value numberRequired
The value to check for
Returns- booleanRequired
-
- containsValue() functionRequired
Checks if a certain value exists in this brush context
Returns true if the values exists for the provided key, returns false otherwise.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to check for
Returns- booleanRequired
-
- end() functionRequired
Ends this brush context
Ends this brush context and emits an 'end' event if it is not already ended.
Parameters- args anyRequired
arguments to be passed to 'end' listeners
-
- intercept() functionRequired
Adds an event interceptor
Parameters- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to call before event is triggered
-
- isActive() functionRequired
Checks if this brush is activated
Returns true if started, false otherwise
Returns- booleanRequired
-
- link() functionRequired
Link this brush to another brush instance.
When linked, the
target
will receive updates whenever this brush changes.Parameters- target BrushRequired
The brush instance to link to
-
- removeAllInterceptors() functionRequired
Removes all interceptors
Parameters- name string
Name of the event to remove interceptors for. If not provided, removes all interceptors.
-
- removeInterceptor() functionRequired
Removes an interceptor
Parameters- name stringRequired
Name of the event to intercept
- ic functionRequired
Handler to remove
-
- removeKeyAlias() functionRequired
Removes an alias
This will only remove the key to alias mapping for new manipulations of the brush, no changes will be made to the current state of this brush.
Parameters- key stringRequired
Value to remove as alias
-
- removeRange() functionRequired
Removes a numeric range from this brush context
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to remove from this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- removeRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to remove
-
- removeValue() functionRequired
Removes a primitive values from this brush context
If the state of the brush changes, ie. if the removed value does exist, an 'update' event is emitted.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to remove
-
- removeValues() functionRequiredParameters
- items Array< object >Required
Items to remove
-
- setRange() functionRequired
Sets a numeric range to this brush context
Overwrites any active ranges identified by
key
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to set on this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- setRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to set
-
- setValues() functionRequiredParameters
- items Array< object >Required
Items to set
-
- start() functionRequired
Starts this brush context
Starts this brush context and emits a 'start' event if it is not already started.
Parameters- args anyRequired
arguments to be passed to 'start' listeners
-
- toggleRange() functionRequired
Toggles a numeric range in this brush context
Removes the range if it's already contained within the given identifier, otherwise the given range is added to the brush.
Parameters- key stringRequired
An identifier that represents the data source of the range
- range objectRequired
The range to toggle in this brush
range properties
- min numberRequired
Min value of the range
- max numberRequired
Max value of the range
-
-
- toggleRanges() functionRequiredParameters
- items Array< object >Required
Items containing the ranges to toggle
-
- toggleValue() functionRequired
Toggles a primitive value in this brush context
If the given value exists in this brush context, it will be removed. If it does not exist it will be added.
Parameters- key stringRequired
An identifier that represents the data source of the value
- value string | numberRequired
The value to toggle
-
- toggleValues() functionRequiredParameters
- items Array< object >Required
Items to toggle
-
-
Brush data by providing a collection of data bound shapes.
Parameters
- shapes Array< SceneNode >Required
An array of data bound shapes.
- config objectRequired
Options
config properties
- components Array< BrushTargetConfig >Required
Array of components to include in the lookup
-
brushFromShapes
const shapes = chartInstance.shapesAt(...);
const config = {
components:[
{
key: 'key1',
contexts: ['myContext'],
data: [''],
action: 'add'
}
]
};
chartInstance.brushFromShapes(shapes, config);
Get a component context
Parameters
- key stringRequired
Component key
Returns
- Required
Component context
properties
- type stringRequired
Type of component
- key stringRequired
Key of the component
-
Get
Parameters
- key stringRequired
Get the dataset identified by
key
Returns
- Required
properties
- extract() functionRequired
Extract data items from this dataset
Parameters- config Extract | DataFieldExtractionRequired
Returns- Array< DatumExtract >Required
-
- field() functionRequired
Find a field within this dataset
Parameters- query stringRequired
The field to find
Returns- Required
properties
- formatter() functionRequired
Returns a formatter adapted to the content of this field.
- id() functionRequired
Returns this field's id
Returns- stringRequired
-
- items() functionRequired
Returns the values of this field.
Returns- Array< DatumExtract >Required
-
- key() functionRequired
Returns this field's key
Returns- stringRequired
-
- max() functionRequired
Returns the max value of this field.
Returns- numberRequired
-
- min() functionRequired
Returns the min value of this field.
Returns- numberRequired
-
- raw() functionRequired
Returns the input data
Returns- anyRequired
-
- tags() functionRequired
Returns the tags.
Returns- Array< string >Required
-
- title() functionRequired
Returns this field's title.
Returns- stringRequired
-
- type() functionRequired
Returns this field's type: 'dimension' or 'measure'.
Returns- stringRequired
-
-
-
- fields() functionRequired
Get all fields within this dataset
Returns- Array< Field >Required
-
- hierarchy() functionRequiredReturns
- nullRequired
-
- key() functionRequired
Get the key identifying this dataset
Returns- stringRequired
-
- raw() functionRequired
Get the raw data
Returns- anyRequired
-
-
Get all nodes matching the provided selector
Parameters
- selector stringRequired
CSS selector [type, attribute, universal, class]
Returns
- Array< SceneNode >Required
Array of objects containing matching nodes
findShapes
chart.findShapes('Circle') // [<CircleNode>, <CircleNode>]
chart.findShapes('Circle[fill="red"][stroke!="black"]') // [CircleNode, CircleNode]
chart.findShapes('Container Rect') // [Rect, Rect]
Get or create a formatter for this chart
Parameters
- v string | objectRequired
Formatter reference or formatter options
Returns
- Required
properties
- formatter() functionRequiredReturns
- anyRequired
Returns a formatted value
-
-
formatter
instance.formatter('nameOfMyFormatter'); // Fetch an existing formatter by name
instance.formatter({ formatter: 'nameOfMyFormatter' }); // Fetch an existing formatter by name
instance.formatter({ type: 'q' }); // Fetch an existing formatter by type
instance.formatter({
formatter: 'd3',
type: 'number',
format: '1.0.%'
}); // Create a new formatter
Get all shapes associated with the provided context
Parameters
- context stringRequired
The brush context
- mode stringRequired
Property comparison mode.
- props Array< string >Required
Which specific data properties to compare
- key stringRequired
Which component to get shapes from. Default gives shapes from all components.
Returns
- Array< object >Required
Array of objects containing shape and parent element
Layout the chart with new settings and / or data
Parameters
- def object
New chart definition
def properties
- data Array< DataSource > | DataSource
Chart data
- settings ChartSettings
Chart settings
settings properties
- components Array< ComponentTypes >
Components
- scales object
Dictionary with scale definitions
- formatters object
Dictionary with formatter definitions
- strategy DockLayoutSettings
Dock layout strategy
strategy properties
- logicalSize object
Logical size
logicalSize properties
- width number
Width in pixels
- height number
Height in pixels
- preserveAspectRatio boolean
If true, takes the smallest ratio of width/height between logical and physical size ( physical / logical )
- align number
Normalized value between 0-1. Defines how the space around the scaled axis is spread in the container, with 0.5 meaning the spread is equal on both sides. Only applicable if preserveAspectRatio is set to true
-
- center object
Define how much space the center dock area requires
center properties
- minWidthRatio number
Value between 0 and 1
- minHeightRatio number
Value between 0 and 1
- minWidth number
Width in pixels
- minHeight number
Height in pixels
-
- layoutModes object
Dictionary with named sizes
- size object
Size is equal to that of the container (element) of the chart by default. It's possible to overwrite it by explicitly setting width or height
size properties
- width number
Width in pixels
- height number
Height in pixels
-
-
- interactions Array< InteractionSettings >
Interaction handlers
- collections Array< CollectionSettings >
Collections
-
- excludeFromUpdate Array< string >
Keys of components to not include in the layout
-
Get or create a scale for this chart
Parameters
- v string | objectRequired
Scale reference or scale options
Returns
- Required
properties
- type stringRequired
Type of scale
-
scale
instance.scale('nameOfMyScale'); // Fetch an existing scale by name
instance.scale({ scale: 'nameOfMyScale' }); // Fetch an existing scale by name
instance.scale({ source: '0/1', type: 'linear' }); // Create a new scale
Get all nodes colliding with a geometrical shape (circle, line, rectangle, point, polygon, geopolygon).
The input shape is identified based on the geometrical attributes in the following order: circle => line => rectangle => point => polygon => geopolygon. Note that not all nodes on a scene have collision detection enabled.
Parameters
-
A geometrical shape. Coordinates are relative to the top-left corner of the chart instance container.
- opts objectRequired
Options
opts properties
- components Array< object >
Array of components to include in the lookup. If no components are specified, all components will be included.
- propagation string
if set to
stop
, will start lookup on top visible component and propagate downwards until a component has at least a match.
-
Returns
- Array< SceneNode >Required
Array of objects containing colliding nodes
shapesAt
chart.shapesAt(
{
x: 0,
y: 0,
width: 100,
height: 100
},
{
components: [
{ key: 'key1', propagation: 'stop' },
{ key: 'key2' }
],
propagation: 'stop'
}
);
Parameters
- val boolean
Toggle brushing on or off. If value is omitted, a toggle action is applied to the current state.
Update the chart with new settings and / or data
Parameters
- def object
New chart definition
def properties
- data Array< DataSource > | DataSource
Chart data
- settings ChartSettings
Chart settings
- partialData boolean
If set to true, will trigger a data update only. Meaning the layout will not be updated
- excludeFromUpdate Array< string >
Keys of components to not include in the update
-
Properties
- beforeDestroy beforeDestroy
beforeDestroy properties
- beforeDestroy() functionRequired
Called before the chart has been destroyed
-
- beforeMount beforeMount
beforeMount properties
- beforeMount() functionRequired
Called before the chart has been mounted
-
- beforeRender beforeRender
beforeRender properties
- beforeRender() functionRequired
Called before the chart has been rendered
-
- beforeUpdate beforeUpdate
beforeUpdate properties
- beforeUpdate() functionRequired
Called before the chart has been updated
-
- created created
created properties
- created() functionRequired
Called when the chart has been created
-
- destroyed destroyed
destroyed properties
- destroyed() functionRequired
Called after the chart has been destroyed
-
- mounted mounted
mounted properties
- mounted() functionRequired
Called after the chart has been mounted
Parameters- element HTMLElementRequired
The element the chart been mounted to
-
-
- updated updated
updated properties
- updated() functionRequired
Called after the chart has been updated
-
- data Array< DataSource > | DataSourceRequired
Chart data
- element HTMLElementRequired
Element to attach chart to
- settings ChartSettingsRequired
Chart settings
settings properties
- components Array< ComponentTypes >
Components
- scales object
Dictionary with scale definitions
- formatters object
Dictionary with formatter definitions
- strategy DockLayoutSettings
Dock layout strategy
strategy properties
- logicalSize object
Logical size
logicalSize properties
- width number
Width in pixels
- height number
Height in pixels
- preserveAspectRatio boolean
If true, takes the smallest ratio of width/height between logical and physical size ( physical / logical )
- align number
Normalized value between 0-1. Defines how the space around the scaled axis is spread in the container, with 0.5 meaning the spread is equal on both sides. Only applicable if preserveAspectRatio is set to true
-
- center object
Define how much space the center dock area requires
center properties
- minWidthRatio number
Value between 0 and 1
- minHeightRatio number
Value between 0 and 1
- minWidth number
Width in pixels
- minHeight number
Height in pixels
-
- layoutModes object
Dictionary with named sizes
- size object
Size is equal to that of the container (element) of the chart by default. It's possible to overwrite it by explicitly setting width or height
size properties
- width number
Width in pixels
- height number
Height in pixels
-
-
- interactions Array< InteractionSettings >
Interaction handlers
- collections Array< CollectionSettings >
Collections
-
Properties
- components Array< ComponentTypes >
Components
- scales object
Dictionary with scale definitions
- formatters object
Dictionary with formatter definitions
- strategy DockLayoutSettings
Dock layout strategy
strategy properties
- logicalSize object
Logical size
logicalSize properties
- width number
Width in pixels
- height number
Height in pixels
- preserveAspectRatio boolean
If true, takes the smallest ratio of width/height between logical and physical size ( physical / logical )
- align number
Normalized value between 0-1. Defines how the space around the scaled axis is spread in the container, with 0.5 meaning the spread is equal on both sides. Only applicable if preserveAspectRatio is set to true
-
- center object
Define how much space the center dock area requires
center properties
- minWidthRatio number
Value between 0 and 1
- minHeightRatio number
Value between 0 and 1
- minWidth number
Width in pixels
- minHeight number
Height in pixels
-
- layoutModes object
Dictionary with named sizes
- size object
Size is equal to that of the container (element) of the chart by default. It's possible to overwrite it by explicitly setting width or height
size properties
- width number
Width in pixels
- height number
Height in pixels
-
-
- interactions Array< InteractionSettings >
Interaction handlers
- collections Array< CollectionSettings >
Collections
Properties
- cx numberRequired
Center x-coordinate
- cy numberRequired
Center y-coordinate
- r numberRequired
Circle radius
Properties
- key stringRequired
Unique key for the collection
- data DataExtractionRequired
Data configuration
data properties
-
Extract definition
- stack object
If provided, defines how the data should be stacked
stack properties
- stackKey StackKeyCallbackRequired
Callback function. Should return the key to stack by
stackKey properties
- StackKeyCallback() functionRequired
Callback function. Should return the key to stack by
Parameters- datum DatumExtractRequired
The extracted datum
Returns- anyRequired
The data value to stack by
-
-
- value StackValueCallbackRequired
Callback function. Should return the data value to stack with
value properties
- StackValueCallback() functionRequired
Callback function. Should return the data value to stack with
Parameters- datum DatumExtractRequired
The extracted datum
Returns- anyRequired
The data value to stack with
-
-
-
- filter FilterCallback
Callback function to filter the extracted data items
filter properties
- FilterCallback() functionRequired
Callback function to filter the extracted data items
Parameters- datum DatumExtractRequired
The extracted datum
Returns- booleanRequired
Return true if the datum should be included in the final data set
-
-
- sort SortCallback
Callback function to sort the extracted data items
sort properties
- SortCallback() functionRequired
Callback function to sort the extracted data items
Parameters- Required
The extracted datum
- Required
The extracted datum
Returns- numberRequired
If less than 0, sort a before b. If greater than 0, sort b before a
-
-
-
CollectionSettings
{
key: 'my-collection',
data: {
extract: [{
source: 'Products',
field: 'Product',
value: d => d.name,
label: d => `<${d.name}>`
props: {
year: { field: 'Year' }
num: { field: 'Sales' }
}
}],
filter: d => d.label !== 'Sneakers', // extract everything except Sneakers
sort: (a, b) => a.label > b.label ? -1 : 1, // sort descending
}
}
Component instance
Properties
- type stringRequired
Type of component
- key stringRequired
Key of the component
Properties
- type 'axis'Required
component type
- scale stringRequired
reference to band or linear scale
- settings DiscreteSettings | ContinuousSettings
discrete or continuous axis settings
ComponentAxis
{
type: 'axis',
scale: '<name-of-scale>'
}
Properties
- type 'box'Required
component type
- data objectRequired
data properties
- min number
Min
- max number
Max
- start number
Start of box
- end number
End of box
- med number
Median
-
- settings objectRequired
settings properties
- major objectRequired
major properties
- scale stringRequired
The scale to use along the major (dimension) axis
- ref string | MajorReference
Reference to the data property along the major axis
-
- minor objectRequired
minor properties
- scale stringRequired
The scale to use along the minor (measure) axis
-
- orientation string
Which orientation to use (vertical or horizontal)
- box object
Visual properties for the box shape in the box marker
box properties
- show boolean
Boolean for showing the box shape
- fill string
- stroke string
- strokeWidth number
- strokeLinejoin string
- width number
- maxWidthPx number
Maximum width of the box in pixels (not applicable when using major start and end)
- minWidthPx number
Minimum width of the box in pixels (not applicable when using major start and end)
- minHeightPx number
Minimum height of the box shape
-
- line object
Visual properties for lines between min-start, end-max.
line properties
- show boolean
- stroke string
- strokeWidth number
-
- whisker object
All the visual properties for whiskers at min and max.
whisker properties
- show boolean
- stroke string
- strokeWidth number
- width number
-
- median object
Visual properties for the median
median properties
- show boolean
- stroke string
- strokeWidth number
-
- oob object
EXPERIMENTAL: Out of bounds symbol utilizing the symbol API
oob properties
- show boolean
- type string
Type of the symbol to be used
- fill string
Fill color of the symbol
- stroke string
Stroke color
- strokeWidth number
Stroke width
- size number
Size/width of the symbol in pixels
- sides number
Number of sides for a n-polygon (3 for triangle)
-
-
ComponentBox
{
type: "box",
data: {
mapTo: {
min: { source: "/qHyperCube/qMeasureInfo/0" },
start: { source: "/qHyperCube/qMeasureInfo/1" },
med: { source: "/qHyperCube/qMeasureInfo/2" },
end: { source: "/qHyperCube/qMeasureInfo/3" },
max: { source: "/qHyperCube/qMeasureInfo/4" },
},
groupBy: {
source: "/qHyperCube/qDimensionInfo/0"
}
},
settings: {
major: {
scale: { source: "/qHyperCube/qDimensionInfo/0" }
},
minor: {
scale: { source: ["/qHyperCube/qMeasureInfo/0",
"/qHyperCube/qMeasureInfo/1",
"/qHyperCube/qMeasureInfo/2",
"/qHyperCube/qMeasureInfo/3",
"/qHyperCube/qMeasureInfo/4"] }
}
}
}
A component that can brush a rectangular area
Properties
- 'brush-area'Required
component type
- objectRequired
settings properties
- objectRequired
brush properties
- Array< BrushTargetConfig >Required
-
-
ComponentBrushArea
{
type: 'brush-area',
brush: {
components: [{ key: '<target-component>', contexts: ['highlight'] }]
}
}
Properties
- 'brush-area-dir'Required
component type
- objectRequired
settings properties
- objectRequired
brush properties
- Array< BrushTargetConfig >Required
-
- string
Rendering direction [horizontal|vertical]
- object
bubbles properties
- boolean
True to show label bubble, false otherwise
- string
Where to anchor bubble [start|end]
- function
Callback function for the labels
-
- object
target properties
- Array< string >
Render matching overlay on target components
-
-
Properties
- type 'brush-lasso'Required
component type
- settings objectRequired
Component settings
settings properties
- lasso object
Lasso style settings
lasso properties
- fill string
- stroke string
- strokeWidth number
- opacity number
- strokeDasharray number
-
- snapIndicator object
Snap indicator settings
snapIndicator properties
- threshold number
The distance in pixel to show the snap indicator, if less then threshold the indicator is dispalyed
- strokeDasharray string
- stroke string
- strokeWidth number
- opacity number
-
- startPoint object
Start point style settings
startPoint properties
- r number
Circle radius
- stroke string
- strokeWidth number
- opacity number
-
- brush object
brush properties
- components Array< object >Required
Array of components to brush on.
-
-
ComponentBrushLasso
{
type: 'brush-lasso',
settings: {
brush: {
components: [{ key: '<target-component>', contexts: ['<brush-context>'] }]
}
},
}
Properties
- type 'brush-range'Required
component type
- settings objectRequired
settings properties
- brush string | objectRequired
Brush context to apply changes to
- scale stringRequired
Scale to extract data from
- direction string
Rendering direction [horizontal|vertical]
- bubbles object
bubbles properties
- show boolean
True to show label bubble, false otherwise
- align string
Where to anchor bubble [start|end]
- label function
Callback function for the labels
-
- target object
target properties
- components Array< string >
Render matching overlay on target components
- selector string
Instead of targeting a component, target one or more shapes
- fillSelector string
Target a subset of the selector as fill area. Only applicable if
selector
property is set
-
-
Properties
- type 'container'Required
component type
ComponentContainer
{
type: 'container',
preferredSize: ({ inner, outer, dock, children }) => {
const sizes = children.map(c => c.preferredSize({ inner, outer }));
return Math.max(...sizes);
},
strategy: (rect, components) => {
const height = rect.height / components.length;
components.forEach((c, i) => {
c.resize({ ...rect, height, y: rect.y + i * height })
});
return { visible: components, hidden: [], order: components };
},
components: [
...
],
}
Properties
- type 'grid-line'Required
component type
- settings objectRequired
Component settings
settings properties
- x objectRequired
x properties
- scale stringRequired
The scale to use along x
-
- y objectRequired
y properties
- scale stringRequired
The scale to use along y
-
- ticks object
ticks properties
- show boolean
- stroke string
- strokeWidth number
- strokeDasharray string
-
- minorTicks object
minorTicks properties
- show boolean
- stroke string
- strokeWidth number
- strokeDasharray string
-
-
ComponentGridLine
{
type: 'grid-line',
settings: {
x: {
scale: '<name-of-scale>',
},
y: {
scale: '<name-of-scale>',
},
},
}
Properties
- type 'labels'Required
component type
- settings objectRequired
Component settings
settings properties
- sources Array< Source >Required
Source settings
-
ComponentLabels
{
type: 'labels',
settings: {
sources: [
{
component: 'bars',
selector: 'rect', // select all 'rect' shapes from the 'bars' component
strategy: {
type: 'bar', // the strategy type
settings: {
labels: [
{
label({ data }) {
return data ? data.end.label : '';
},
placements: [
// label placements in prio order. Label will be placed in the first place it fits into
{ position: 'inside', fill: '#fff' },
{ position: 'outside', fill: '#666' },
],
},
],
},
},
},
],
},
}
Properties
- type 'legend-cat'Required
component type
- scale stringRequired
Reference to categorical color scale
- settings object
Component settings
settings properties
- item object
Settings applied per item
item properties
- align number
Align item
- justify number
Justify item
- label object
label properties
- fontFamily string
Font family
- fontSize string
Font size in pixels
- lineHeight number
Line height as a multiple of the font size
- maxLines number
Max number of lines allowed if label is broken into multiple lines (only applicable with wordBreak)
- maxWidth number
Maximum width of label, in px
- wordBreak string
Word break rule, how to apply line break if label text overflows its maxWidth property. Either
'break-word'
or'break-all'
-
- shape object
shape properties
- size number
Size of shape in pixels
- type string
Type of shape
-
- show boolean
Whether to show the current item
-
- layout object
layout properties
- direction string
Layout direction. Either
'ltr'
or'rtl'
- scrollOffset number
Initial scroll offset
- size number
Maximum number of columns (vertical) or rows (horizontal)
-
- object
navigation properties
- object
button properties
- object
- functionRequired
- number
-
- boolean
Whether the button should be disabled or not
-
- title object
title properties
- anchor stringRequired
Horizontal alignment of the text. Allowed values are
'start'
,'middle'
and'end'
- fill string
Title color
- fontFamily string
Font family
- fontSize string
Font size in pixels
- lineHeight number
Line height as a multiple of the font size
- maxLines number
Max number of lines allowed if label is broken into multiple lines, is only appled when
wordBreak
is not set to'none'
- maxWidth number
Maximum width of title, in px
- show boolean
Whether to show the title
- text string
Title text. Defaults to the title of the provided data field
- wordBreak string
Word break rule, how to apply line break if label text overflows its maxWidth property. Either
'break-word'
or'break-all'
-
-
ComponentLegendCat
{
type: 'legend-cat',
scale: '<categorical-color-scale>',
}
Properties
- type 'legend-seq'Required
component type
- settings objectRequired
Component settings
settings properties
- fill stringRequired
Reference to definition of sequential color scale
- major stringRequired
Reference to definition of linear scale
- size number
Size in pixels of the legend, if vertical is the width and height otherwise
- length number
A value in the range 0-1 indicating the length of the legend node
- maxLengthPx number
Max length in pixels
- align number
A value in the range 0-1 indicating horizontal alignment of the legend's content. 0 aligns to the left, 1 to the right.
- justify number
A value in the range 0-1 indicating vertical alignment of the legend's content. 0 aligns to the top, 1 to the bottom.
- padding object
padding properties
- left number
Size in pixels
- right number
Size in pixels
- top number
Size in pixels
- bottom number
Size in pixels
-
- tick object
tick properties
- label function
Function applied to all tick values. Return value should be a string and is used as label
- fill string
Tick color
- fontSize string
Font size in pixels
- fontFamily string
Font family
- maxLengthPx number
Max length in pixels
- anchor string
Where to anchor the tick in relation to the legend node, supported values are [top, bottom, left and right] or empty string to auto anchor
- padding number
padding in pixels to the legend node
-
- title object
Title settings
title properties
- show boolean
Toggle title on/off
- text string
Title text. Defaults to the title of the provided data field
- fill string
Title color
- fontSize string
Font size in pixels
- fontFamily string
Font family
- maxLengthPx number
Max length in pixels
- padding number
padding in pixels to the legend node
- anchor string
Where to anchor the title in relation to the legend node, supported values are [top, left and right] or empty string to auto anchor
- wordBreak string
How overflowing title is handled, if it should insert line breaks at word boundries (break-word) or character boundries (break-all)
- hyphens string
How words should be hyphenated when text wraps across multiple lines (only applicable with wordBreak)
- maxLines number
Number of allowed lines if title contains line breaks (only applicable with wordBreak)
- lineHeight number
A multiplier defining the distance between lines (only applicable with wordBreak)
-
-
ComponentLegendSeq
{
type: 'legend-seq',
settings: {
fill: '<sequential-color-scale>',
major: '<linear-scale>',
}
}
Properties
- type 'line'Required
component type
- settings objectRequired
Component settings
settings properties
- connect boolean
- coordinates objectRequired
coordinates properties
- defined DatumBoolean
defined properties
- DatumBoolean boolean | DatumConfig | datumAccessorRequired
Custom type that is either a boolean, DatumConfig or a datumAccessor
-
- layerId number
- major numberRequired
- minor numberRequired
-
- layers objectRequired
layers properties
- area objectRequired
area properties
- fill string
- opacity number
- show boolean
-
- curve string
- line objectRequired
line properties
- opacity number
- show boolean
- showMinor0 boolean
- stroke string
- strokeDasharray string
- strokeLinejoin string
- strokeWidth number
-
- show boolean
- sort LayerSort
sort properties
- LayerSort() functionRequired
Callback function for layer sort
Parameters- a objectRequired
a properties
- id stringRequired
- data Array< DatumExtract >Required
-
- b objectRequired
b properties
- id stringRequired
- data Array< DatumExtract >Required
-
-
-
-
- orientation string
-
ComponentLine
{
type: "line",
data: {
extract: {
field: "Year",
props: {
sales: { field: "Sales" },
},
},
},
settings: {
coordinates: {
major: { scale: "t" },
minor: { scale: "y", ref: "sales" },
},
},
}
Properties
- type 'pie'Required
component type
- settings objectRequired
Component settings
settings properties
- endAngle number
End angle of the pie, in radians
- slice objectRequired
slice properties
- arc number
Absolute value of the slice's arc length
- cornerRadius number
Corner radius of the slice, in pixels
- fill string
Fill color of the slice
- innerRadius number
Inner radius of the slice
- offset number
Radial offset of the slice
- opacity number
Opacity of the slice
- outerRadius number
Outer radius of the slice
- show boolean
Visibility of the slice
- stroke string
Stroke color of the slice
- strokeLinejoin string
Stroke line join
- strokeWidth number
Stroke width of the slice
-
- startAngle number
Start angle of the pie, in radians
-
ComponentPie
{
type: 'pie',
data: {
extract: {
field: 'Region',
props: {
num: { field: 'Population' }
}
}
},
settings: {
startAngle: Math.PI / 2,
endAngle: -Math.PI / 2,
slice: {
arc: { ref: 'num' },
fill: 'green',
stroke: 'red',
strokeWidth: 2,
strokeLinejoin: 'round',
innerRadius: 0.6,
outerRadius 0.8,
opacity: 0.8,
offset: 0.2
}
}
}
Properties
- type 'point'Required
component type
- settings object
Component settings
settings properties
- fill DatumString
Fill color
fill properties
- DatumString string | DatumConfig | datumAccessorRequired
Custom type that is either a string, DatumConfig or a datumAccessor
-
- label DatumString
Label
- opacity DatumNumber
Opacity of shape
opacity properties
- DatumNumber number | DatumConfig | datumAccessorRequired
Custom type that is either a number, DatumConfig or a datumAccessor
-
- shape DatumString
Type of shape
- show DatumBoolean
Whether or not to show the point
show properties
- DatumBoolean boolean | DatumConfig | datumAccessorRequired
Custom type that is either a boolean, DatumConfig or a datumAccessor
-
- size DatumNumber
Normalized size of shape
- sizeLimits object
sizeLimits properties
- maxPx number
Maximum size of shape, in pixels
- maxRelDiscrete number
Maximum size relative discrete scale banwidth
- maxRelExtent number
Maximum size relative linear scale extent
- minPx number
Minimum size of shape, in pixels
- minRelDiscrete number
Minimum size relative discrete scale banwidth
- minRelExtent number
Minimum size relative linear scale extent
-
- stroke DatumString
Stroke color
- strokeDasharray DatumString
Stroke dash array
- strokeLinejoin DatumString
Stroke line join
- strokeWidth DatumNumber
Stroke width
-
Normalized x coordinate
-
Normalized y coordinate
-
ComponentPoint
{
type: 'point',
data: {
extract: {
field: 'Month',
props: {
x: { field: 'Margin' },
y: { field: 'Year' }
}
}
},
settings: {
x: { scale: 'm' },
y: { scale: 'y' },
}
}
ComponentRefLine
{
type: 'ref-line',
lines: {
y: [{
scale: 'y',
value: 5000,
label: {
text: 'value label'
}
slope: 0.5,
}]
}
}
Generic settings available to all components
Properties
- type stringRequired
Component type (ex: axis, point, ...)
- preferredSize function
Function returning the preferred size
- created function
Called when the component has been created
- beforeMount function
Called before the component has been mounted
- mounted function
Called after the component has been mounted
- beforeUpdate function
Called before the component has been updated
- updated function
Called after the component has been updated
- beforeRender function
Called before the component has been rendered
- beforeDestroy function
Called before the component has been destroyed
- destroyed function
Called after the component has been destroyed
- brush object
Brush settings
brush properties
- trigger Array< BrushTriggerSettings >
Trigger settings
- consume Array< BrushConsumeSettings >
Consume settings
- sortNodes function
Sorting function for nodes. Should return sorted nodes.
-
- layout object
Layout settings
layout properties
- displayOrder number
- prioOrder number
- minimumLayoutMode string | Object
Refer to layout sizes defined by layoutModes in
strategy
- dock string
left, right, top or bottom
-
- show boolean
If the component should be rendered
- scale string
Named scale. Will be provided to the component if it asks for it.
- formatter string
Named formatter. Fallback to create formatter from scale. Will be provided to the component if it asks for it.
- components Array< ComponentSettings >Experimental
Optional list of child components
- strategy DockLayoutSettings | customLayoutFunctionExperimental
Layout strategy used for child components.
-
Extracted data that should be available to the component
- rendererSettings RendererSettings
Settings for the renderer used to render the component
rendererSettings properties
- transform TransformFunction
Setting for applying transform without re-rendering the whole component completely.
transform properties
- TransformFunction() functionRequiredExperimental
Should return a transform object if transformation should be applied, otherwise undefined or a falsy value. Transforms can be applied with the canvas, svg and dom renderer. Transform is applied when running chart.update, see example. !Important: When a transform is applied to a component, the underlaying node representations are not updated with the new positions/sizes, which can cause problems for operations that relies on the positioning of the shapes/nodes (such as tooltips, selections etc). An extra chart update without a transform is therefore needed to make sure the node position information is in sync with the visual representation again.
Returns- Required
-
-
- canvasBufferSize CanvasBufferSize
Specifies the size of buffer canvas (used together with transform setting).
canvasBufferSize properties
- CanvasBufferSize function | objectRequiredExperimental
An object containing width and height of the canvas buffer or a function returning an object on that format. Gets a rect object as input parameter.
-
- progressive Progressive
Setting for applying progressive rendering to a canvas renderer
progressive properties
- Progressive() functionRequiredExperimental
A function which returns either (1) false (to specify no progressive rendering used) or an object specifing the data chunk rendered. This is only applied to a canvas renderer.
Returns- ProgressiveObject | booleanRequired
-
-
-
- key string
Component key
Properties
- type 'text'Required
component type
- text string | functionRequired
Text to display
- settings objectRequired
settings properties
- paddingStart number
Start padding in pixels
- paddingEnd number
End padding in pixels
- paddingLeft number
Left padding in pixels
- paddingRight number
Right padding in pixels
- anchor string
Where to v- or h-align the text. Supports
left
,right
,top
,bottom
andcenter
- join string
String to add when joining titles from multiple sources
- maxLengthPx number
Limit the text length
-
- style objectRequired
style properties
- text object
text properties
- fontSize string
Font size of text
- fontFamily string
Font family of text
- fontWeight string
Font weight of text
- fill string
Fill color of text
- stroke string
Stroke of text
- strokeWidth number
Stroke width of text
- opacity number
Opacity of text
-
-
ComponentText
{
type: 'text',
text: 'my title',
dock: 'left',
settings: {
anchor: 'left',
}
}
Properties
- type 'tooltip'Required
component type
- settings objectRequired
settings properties
- afterHide() function
Component lifecycle hook. Called after the tooltip is hidden.
- afterShow() function
Component lifecycle hook. Called after the tooltip have been displayed.
- appendTo HTMLElement
Explicitly set a target element. This allows the tooltip to attach itself outside the picasso container.
- arrowClass object
Set arrow class.
- beforeHide() function
Component lifecycle hook. Called before the tooltip is hidden.
Parameters- ctx objectRequired
Callback paramater
ctx properties
- element HTMLElementRequired
The element the tooltip is appended to
-
-
- beforeShow() function
Component lifecycle hook. Called before the tooltip is displayed.
- content() function
Callback function to generate content. Should return an array of Virtual DOM Elements.
Parameters- ctx objectRequired
Callback context
ctx properties
- data Array< any >Required
An array of data generated from the
extract
function - h objectRequired
A function for creating Virtual DOM Elements. See API reference for preactjs
h
function
-
Returns- Array< object >Required
An array of Virtual DOM Elements
-
- contentClass object
Set content class.
- delay number
Delay before the tooltip is rendered, in milliseconds
- direction string
Content direction [ltr | rtl]
- duration number
How long the tooltip is visible, in milliseconds
- extract() function
Callback function called for each node to extract data. Can return any type.
Parameters- ctx objectRequired
Callback context
ctx properties
- node SceneNodeRequired
Node
node properties
- attrs objectRequired
Node attributes
- bounds RectRequired
Bounding rectangle of the node. After any transform has been applied, if any, but excluding scaling transform related to devicePixelRatio. Origin is in the top-left corner of the scene element.
bounds properties
- x numberRequired
X-coordinate
- y numberRequired
Y-coordinate
- width numberRequired
Width
- height numberRequired
Height
-
- boundsRelativeTo() functionRequired
Bounding rectangle of the node, relative a target.
If target is an HTMLElement, the bounds are relative to the HTMLElement. Any other target type will return the bounds relative to the viewport of the browser.
Parameters- target HTMLElement | anyRequired
- includeTransform booleanRequired
Whether to include any applied transforms on the node
Returns- Required
-
- children Array< SceneNode >Required
Get child nodes
-
Collider of the node. Transform on the node has been applied to the collider shape, if any, but excluding scaling transform related to devicePixelRatio. Origin is in the top-left corner of the scene element.
If node has no collider, null is returned.
- data anyRequired
Get the associated data
- desc objectRequired
Node description
- element HTMLElementRequired
Element the scene is attached to
- key stringRequired
Key of the component this shape belongs to
- localBounds RectRequired
Bounding rectangle of the node within its local coordinate system. Origin is in the top-left corner of the scene element.
- parent SceneNodeRequired
Get parent node
- tag stringRequired
Node tag
- type stringRequired
Node type
-
-
Returns- anyRequired
Return data
-
- filter() function
Callback function to filter incoming nodes to only a set of applicable nodes. Is called as a part of the
show
event.Should return an array of SceneNodes.
Parameters- nodes Array< SceneNode >Required
Array of SceneNodes
Returns- Array< SceneNode >Required
An array of SceneNodes
-
- isEqual() function
Comparison function. If evaluted to true, the incoming nodes in the
show
event are ignored. If evaluated to false, any active tooltip is cleared and a new tooltip is queued.The function gets two parameters, the first is the currently active set of nodes, if any, and the second is the incoming set of nodes. By default the two set of nodes are considered equal if their data attributes are the same.
Parameters- prev Array< SceneNode >Required
Previous array of SceneNodes
- curr Array< SceneNode >Required
Current array of SceneNodes
Returns- booleanRequired
-
- onHide() function
Component lifecycle hook. Called when the toolip is hidden. By default this deletes the tooltip element.
Parameters- ctx objectRequired
Callback paramater
ctx properties
- element HTMLElementRequired
The element the tooltip is appended to
-
-
- placement object
placement properties
- area number
Specify the limiting area, where target is the component area unless the appendTo property is set, in which case it referes to the appendTo element. Viewport is the browser viewport.
Available options are: [viewport | target]
- dock string
Docking position of the tooltip. Available positions: [left | right | top | bottom | auto]
- offset number
Distance from the content area to the tooltip position, in px.
- type string
Available types: [pointer | bounds | slice]
-
- tooltipClass object
Set tooltip class.
-
ComponentTooltip
picasso.chart({
settings: {
interactions: [{
type: 'native',
events: {
mousemove(e) {
const tooltip = this.chart.component('<tooltip-key>');
tooltip.emit('show', e);
},
mouseleave(e) {
const tooltip = this.chart.component('<tooltip-key>');
tooltip.emit('hide');
}
}
}],
components: [
{
key: '<tooltip-key>',
type: 'tooltip'
}
]
},
...
});
ComponentTypes ComponentAxis | ComponentBox | ComponentBrushArea | ComponentBrushAreaDir | ComponentBrushLasso | ComponentBrushRange | ComponentContainer | ComponentGridLine | ComponentLabels | ComponentLegendCat | ComponentLegendSeq | ComponentLine | ComponentPie | ComponentPoint | ComponentRefLine | ComponentText | ComponentTooltip
Parameters
- rect RectRequired
rect properties
- x numberRequired
X-coordinate
- y numberRequired
Y-coordinate
- width numberRequired
Width
- height numberRequired
Height
-
- components Array< object >Required
Used to extract data from a DataSource
Properties
-
Extract definition
- stack object
If provided, defines how the data should be stacked
stack properties
- stackKey StackKeyCallbackRequired
Callback function. Should return the key to stack by
stackKey properties
- StackKeyCallback() functionRequired
Callback function. Should return the key to stack by
Parameters- datum DatumExtractRequired
The extracted datum
Returns- anyRequired
The data value to stack by
-
-
- value StackValueCallbackRequired
Callback function. Should return the data value to stack with
value properties
- StackValueCallback() functionRequired
Callback function. Should return the data value to stack with
Parameters- datum DatumExtractRequired
The extracted datum
Returns- anyRequired
The data value to stack with
-
-
-
- filter FilterCallback
Callback function to filter the extracted data items
filter properties
- FilterCallback() functionRequired
Callback function to filter the extracted data items
Parameters- datum DatumExtractRequired
The extracted datum
Returns- booleanRequired
Return true if the datum should be included in the final data set
-
-
- sort SortCallback
Callback function to sort the extracted data items
sort properties
- SortCallback() functionRequired
Callback function to sort the extracted data items
Parameters- Required
The extracted datum
- Required
The extracted datum
Returns- numberRequired
If less than 0, sort a before b. If greater than 0, sort b before a
-
-
DataExtraction
{
extract: [{
source: 'Products',
field: 'Product',
value: d => d.name,
label: d => `<${d.name}>`
props: {
year: { field: 'Year' }
num: { field: 'Sales' }
}
}],
filter: d => d.label !== 'Sneakers', // extract everything except Sneakers
sort: (a, b) => a.label > b.label ? -1 : 1, // sort descending
}
DataFieldExtraction
{
source: 'Products',
field: 'Sales',
value: (val) => Math.round(val),
label: (val) => `<${val}>`
}
Extract data items from this dataset
Parameters
- config Extract | DataFieldExtractionRequired
Returns
- Array< DatumExtract >Required
Find a field within this dataset
Parameters
- query stringRequired
The field to find
Returns
- Required
properties
- formatter() functionRequired
Returns a formatter adapted to the content of this field.
- id() functionRequired
Returns this field's id
Returns- stringRequired
-
- items() functionRequired
Returns the values of this field.
Returns- Array< DatumExtract >Required
-
- key() functionRequired
Returns this field's key
Returns- stringRequired
-
- max() functionRequired
Returns the max value of this field.
Returns- numberRequired
-
- min() functionRequired
Returns the min value of this field.
Returns- numberRequired
-
- raw() functionRequired
Returns the input data
Returns- anyRequired
-
- tags() functionRequired
Returns the tags.
Returns- Array< string >Required
-
- title() functionRequired
Returns this field's title.
Returns- stringRequired
-
- type() functionRequired
Returns this field's type: 'dimension' or 'measure'.
Returns- stringRequired
-
-
Get all fields within this dataset
Returns
- Array< Field >Required
Properties
- key string
Unique identifier for this data source
- type stringRequired
The dataset type
- data anyRequired
Data
Callback function
Parameters
- Required
datum
d properties
- value anyRequired
The extracted value
- label stringRequired
The extracted value as a string
- source objectRequired
The data source of the extracted data
source properties
- key stringRequired
The data-source key
- field stringRequired
The source field
-
-
datumAccessor
(d) => Math.min(0, d.value);
DatumBoolean boolean | DatumConfig | datumAccessor
Custom type that is either a boolean, DatumConfig or a datumAccessor
Properties
- scale string
Name of a scale
-
fn properties
- datumAccessor() functionRequired
Callback function
Parameters- Required
datum
d properties
- value anyRequired
The extracted value
- label stringRequired
The extracted value as a string
- source objectRequired
The data source of the extracted data
source properties
- key stringRequired
The data-source key
- field stringRequired
The source field
-
-
-
-
- ref string
A reference to a DatumExtract property
DatumConfig
// Implicitly resolve the datum by passing a referenced data through the scale
{
scale: '<name-of-scale>',
ref: '<data-property>'
}
// or explicitly resolve the datum using callback function
{
fn: (d) => Math.min(0, d.datum.x.value);
}
Properties
- value anyRequired
The extracted value
- label stringRequired
The extracted value as a string
- source objectRequired
The data source of the extracted data
source properties
- key stringRequired
The data-source key
- field stringRequired
The source field
-
DatumNumber number | DatumConfig | datumAccessor
Custom type that is either a number, DatumConfig or a datumAccessor
DatumString string | DatumConfig | datumAccessor
Custom type that is either a string, DatumConfig or a datumAccessor
Dock layout settings
Properties
- logicalSize object
Logical size
logicalSize properties
- width number
Width in pixels
- height number
Height in pixels
- preserveAspectRatio boolean
If true, takes the smallest ratio of width/height between logical and physical size ( physical / logical )
- align number
Normalized value between 0-1. Defines how the space around the scaled axis is spread in the container, with 0.5 meaning the spread is equal on both sides. Only applicable if preserveAspectRatio is set to true
-
- center object
Define how much space the center dock area requires
center properties
- minWidthRatio number
Value between 0 and 1
- minHeightRatio number
Value between 0 and 1
- minWidth number
Width in pixels
- minHeight number
Height in pixels
-
- layoutModes object
Dictionary with named sizes
- size object
Size is equal to that of the container (element) of the chart by default. It's possible to overwrite it by explicitly setting width or height
size properties
- width number
Width in pixels
- height number
Height in pixels
-
Returns the values of this field.
Returns
- Array< DatumExtract >Required
Properties
- formatter string
Name of the formatter
- type string
Type of formatter
- format string
Format string
-
The data to create formatter from
Properties
- polygons Array< Polygon >Required
Array of polygons
Interaction instance
Properties
- on functionRequired
Enable interaction
- off functionRequired
Disable interaction
- destroy functionRequired
Destroy interaction
- key stringRequired
Interaction identifier
Properties
- type stringRequired
Type of interaction handler
- key string
Unique key identifying the handler
- enable function | booleanRequired
Enable or disable the interaction handler. If a callback function is provided, it must return either true or false
InteractionSettings
{
type: 'native',
key: 'nativeHandler',
enable: () => true,
events: { // "events" is a property specific to the native handler
mousemove: (e) => console.log('mousemove', e),
}
}
Properties
- x1 numberRequired
Start x-coordinate
- y1 numberRequired
Start y-coordinate
- x2 numberRequired
End x-coordinate
- y2 numberRequired
End y-coordinate
Callback function to register a plugin
Parameters
- registries RegistriesRequired
registries properties
- component registryRequired
Component registry
component properties
- registry() functionRequired
Register a
value
with the givenkey
. Ifvalue
is omitted, returns thevalue
ofkey
.Parameters- key stringRequired
Name of the type to register
- value any
Value to store in the registry.
Returns- anyRequired
Registered value
-
-
- data registryRequired
Data registry
- formatter registryRequired
Formatter registry
- interaction registryRequired
Interaction registry
- renderer registryRequired
Renderer registry
- scale registryRequired
Scale registry
-
- options objectRequired
Properties
- points Array< Point >Required
Array of connected points
Properties
- points Array< Point >Required
Array of connected points
A format to represent a data chunk to be rendered.
Properties
- start numberRequired
Start index of a data chunk.
- end numberRequired
End index of a data chunk.
- isFirst booleanRequired
If it is the first data chunk rendered. This helps to clear a canvas before rendering.
- isLast booleanRequired
If it is the last data chunk rendered. This helps to update other components depending on a component with progressive rendering.
Properties
- x numberRequired
X-coordinate
- y numberRequired
Y-coordinate
- width numberRequired
Width
- height numberRequired
Height
Properties
- component registryRequired
Component registry
component properties
- registry() functionRequired
Register a
value
with the givenkey
. Ifvalue
is omitted, returns thevalue
ofkey
.Parameters- key stringRequired
Name of the type to register
- value any
Value to store in the registry.
Returns- anyRequired
Registered value
-
-
- data registryRequired
Data registry
- formatter registryRequired
Formatter registry
- interaction registryRequired
Interaction registry
- renderer registryRequired
Renderer registry
- scale registryRequired
Scale registry
Register a value
with the given key
. If value
is omitted, returns the value
of key
.
Parameters
- key stringRequired
Name of the type to register
- value any
Value to store in the registry.
Returns
- anyRequired
Registered value
Parameters
- element HTMLElementRequired
Element to attach renderer to
Returns
- HTMLElementRequired
Root element of the renderer
Clear all child elements from the renderer root element
Returns
- Required
The renderer instance
Get the element this renderer is attached to
Returns
- HTMLElementRequired
Get all nodes matching the provided selector
Parameters
- selector stringRequired
CSS selector [type, attribute, universal, class]
Returns
- Array< SceneNode >Required
Array of objects containing matching nodes
Parameters
- opts objectRequired
opts properties
- text stringRequired
Text to measure
- fontSize stringRequired
Font size
- fontFamily stringRequired
Font family
-
Returns
- objectRequired
Width and height of text
measureText
measureText({
text: 'my text',
fontSize: '12px',
fontFamily: 'Arial'
}); // returns { width: 20, height: 12 }
Parameters
- nodes Array< object >Required
Nodes to render
Returns
- booleanRequired
True if the nodes were rendered, otherwise false
Set or Get renderer settings
Parameters
- settings object
Settings for the renderer
Set or Get the size definition of the renderer container.
Parameters
- opts SizeDefinition
Size definition
opts properties
- x number
x-coordinate
- y number
y-coordinate
- width number
Width
- height number
Height
- scaleRatio object
scaleRatio properties
- x number
Scale ratio on x-axis
- y number
Scale ratio on y-axis
-
- margin object
margin properties
- left number
Left margin
- top number
Top margin
-
-
Returns
- Required
The current size definition
Properties
- transform TransformFunction
Setting for applying transform without re-rendering the whole component completely.
transform properties
- TransformFunction() functionRequiredExperimental
Should return a transform object if transformation should be applied, otherwise undefined or a falsy value. Transforms can be applied with the canvas, svg and dom renderer. Transform is applied when running chart.update, see example. !Important: When a transform is applied to a component, the underlaying node representations are not updated with the new positions/sizes, which can cause problems for operations that relies on the positioning of the shapes/nodes (such as tooltips, selections etc). An extra chart update without a transform is therefore needed to make sure the node position information is in sync with the visual representation again.
Returns- Required
-
-
- canvasBufferSize CanvasBufferSize
Specifies the size of buffer canvas (used together with transform setting).
canvasBufferSize properties
- CanvasBufferSize function | objectRequiredExperimental
An object containing width and height of the canvas buffer or a function returning an object on that format. Gets a rect object as input parameter.
-
- progressive Progressive
Setting for applying progressive rendering to a canvas renderer
progressive properties
- Progressive() functionRequiredExperimental
A function which returns either (1) false (to specify no progressive rendering used) or an object specifing the data chunk rendered. This is only applied to a canvas renderer.
Returns- ProgressiveObject | booleanRequired
-
-
Properties
- type string
- padding number
Sets both inner and outer padding to the same value
- paddingInner number
Inner padding
- paddingOuter number
Outer padding
- align number
Control how the outer padding should be distributed, where 0.5 would distribute the padding equally on both sides
- invert boolean
Invert the output range
- maxPxStep number
Explicitly limit the bandwidth to a pixel value
- label function
Callback label function, applied on each datum
- value function
Callback value function, applied on each datum
- range Array< number > | function
Set range explicitly (ignored when maxPxStep takes effect)
Properties
- type string
- range Array< string >
CSS color values of the output range
- unknown string
Value to return when input value is unknown
- explicit object
Explicitly bind values to an output
explicit properties
- domain[] Array< object >
Values to bind
- range[] Array< string >
Output range
-
Definition for creating a scale. Additional properties, specific for a type of scale, can be added as key/value pairs
Properties
- type string
Type of scale
-
Data configuration
Properties
- type string
- expand number
Expand the output range
- invert boolean
Invert the output range
- include Array< number >
Include specified numbers in the output range
- ticks object
ticks properties
- tight boolean
- forceBounds boolean
- distance number
Approximate distance between each tick
- values Array< number > | Array< object >
If set, ticks are no longer generated but instead equal to this set
- count number
-
- minorTicks object
minorTicks properties
- count number
-
- min number
Set an explicit minimum value
- max number
Set an explicit maximum value
Properties
- type string
- range Array< string >
CSS color values of the output range
- invert boolean
Invert range
- min number
Set an explicit minimum value
- max number
Set an explicit maximum value
Properties
- type string
- domain Array< number >
Values defining the thresholds
- range Array< string >
CSS color values of the output range
- invert boolean
Invert range
- min number
Set an explicit minimum value
- max number
Set an explicit maximum value
- nice boolean
If set to true, will generate 'nice' domain values. Ignored if domain is set.
Read-only object representing a node on the scene.
Properties
- attrs objectRequired
Node attributes
- bounds RectRequired
Bounding rectangle of the node. After any transform has been applied, if any, but excluding scaling transform related to devicePixelRatio. Origin is in the top-left corner of the scene element.
bounds properties
- x numberRequired
X-coordinate
- y numberRequired
Y-coordinate
- width numberRequired
Width
- height numberRequired
Height
-
- children Array< SceneNode >Required
Get child nodes
-
Collider of the node. Transform on the node has been applied to the collider shape, if any, but excluding scaling transform related to devicePixelRatio. Origin is in the top-left corner of the scene element.
If node has no collider, null is returned.
- data anyRequired
Get the associated data
- desc objectRequired
Node description
- element HTMLElementRequired
Element the scene is attached to
- key stringRequired
Key of the component this shape belongs to
- localBounds RectRequired
Bounding rectangle of the node within its local coordinate system. Origin is in the top-left corner of the scene element.
- parent SceneNodeRequired
Get parent node
- tag stringRequired
Node tag
- type stringRequired
Node type
Bounding rectangle of the node, relative a target.
If target is an HTMLElement, the bounds are relative to the HTMLElement. Any other target type will return the bounds relative to the viewport of the browser.
Parameters
- target HTMLElement | anyRequired
- includeTransform booleanRequired
Whether to include any applied transforms on the node
Returns
- Required
boundsRelativeTo
node.boundsRelativeTo($('div'));
node.boundsRelativeTo('viewport');
Create a new svg renderer
Parameters
- treeFactory function
Node tree factory
- ns string
Namespace definition
- sceneFn function
Scene factory
Returns
- Required
A svg renderer instance
properties
- appendTo() functionRequiredParameters
- element HTMLElementRequired
Element to attach renderer to
Returns- HTMLElementRequired
Root element of the renderer
-
- clear() functionRequired
Clear all child elements from the renderer root element
Returns- Required
The renderer instance
-
- destory() functionRequired
Remove the renderer root element from its parent element
- element() functionRequired
Get the element this renderer is attached to
Returns- HTMLElementRequired
-
- findShapes() functionRequired
Get all nodes matching the provided selector
Parameters- selector stringRequired
CSS selector [type, attribute, universal, class]
Returns- Array< SceneNode >Required
Array of objects containing matching nodes
-
- itemsAt() functionRequired
Get nodes renderer at area
Parameters-
Get nodes that intersects with geometry
Returns- Array< SceneNode >Required
-
- measureText() functionRequiredParameters
- opts objectRequired
opts properties
- text stringRequired
Text to measure
- fontSize stringRequired
Font size
- fontFamily stringRequired
Font family
-
Returns- objectRequired
Width and height of text
-
- render() functionRequiredParameters
- nodes Array< object >Required
Nodes to render
Returns- booleanRequired
True if the nodes were rendered, otherwise false
-
- root() functionRequired
Get the root element of the renderer
Returns- HTMLElementRequired
-
- settings() functionRequired
Set or Get renderer settings
Parameters- settings object
Settings for the renderer
-
- size() functionRequired
Set or Get the size definition of the renderer container.
Parameters- opts SizeDefinition
Size definition
opts properties
- x number
x-coordinate
- y number
y-coordinate
- width number
Width
- height number
Height
- scaleRatio object
scaleRatio properties
- x number
Scale ratio on x-axis
- y number
Scale ratio on y-axis
-
- margin object
margin properties
- left number
Left margin
- top number
Top margin
-
-
Returns- Required
The current size definition
-
-
A format to represent a transformation.
Properties
- horizontalScaling numberRequired
- horizontalSkewing numberRequired
- verticalSkewing numberRequired
- verticalScaling numberRequired
- horizontalMoving numberRequired
- verticalMoving numberRequired
Properties
- includeMax boolean
Whether or not the maximum value of a range should be included when determining if a value is brushed.
- includeMin boolean
Whether or not the minimum value of a range should be included when determining if a value is brushed.
- key string
An identifier that represents the data source of the value
Called after the chart has been mounted
Parameters
- element HTMLElementRequired
The element the chart been mounted to
Continuous axis settings
Properties
- arc ArcSettings
Optional arc settings
- align string
Set the anchoring point of the axis. Available options are
auto/left/right/bottom/top
. Inauto
the axis determines the best option. The options are restricted based on the axis orientation, a vertical axis may only anchor onleft
orright
- labels objectRequired
labels properties
- align number
Align act as a slider for the text bounding rect over the item bandwidth, given that the item have a bandwidth.
- filterOverlapping boolean
Toggle whether labels should be filtered if they are overlapping. Filtering may be applied in a non-sequential order. If labels are overlapping and this setting is toggled off, the axis will automatically hide.
- margin number
Space in pixels between the tick and label.
- maxLengthPx number
Max length of labels in pixels
- minLengthPx number
Min length of labels in pixels. Labels will always at least require this much space
- offset number
Offset in pixels along the axis direction.
- show boolean
Toggle labels on/off
-
- line objectRequired
line properties
- show boolean
Toggle line on/off
-
- minorTicks objectRequired
minorTicks properties
- margin number
Space in pixels between the ticks and the line.
- show boolean
Toggle minor-ticks on/off
- tickSize number
Size of the ticks in pixels.
-
- paddingEnd number
Padding in direction perpendicular to the axis
- paddingStart number
Padding in direction perpendicular to the axis
- ticks objectRequired
ticks properties
- margin number
Space in pixels between the ticks and the line.
- show boolean
Toggle ticks on/off
- tickSize number
Size of the ticks in pixels.
-
ContinuousSettings
{
type: 'axis',
scale: '<name-of-linear-scale>',
settings: {
minorTicks: {
show: false,
},
},
}
Discrete axis settings
Properties
- align string
Set the anchoring point of the axis. Available options are
auto/left/right/bottom/top
. Inauto
the axis determines the best option. The options are restricted based on the axis orientation, a vertical axis may only anchor onleft
orright
- labels objectRequired
labels properties
- align number
Align act as a slider for the text bounding rect over the item bandwidth, given that the item have a bandwidth. Except when labels are tilted, then the align is a pure align that shifts the position of the label anchoring point.
- filterOverlapping boolean
Toggle whether labels should be filtered if they are overlapping. Filtering may be applied in a non-sequential order. If labels are overlapping and this setting is toggled off, the axis will automatically hide.
- margin number
Space in pixels between the tick and label.
- maxEdgeBleed number
Control the amount of space (in pixels) that labes can occupy outside their docking area. Only applicable when labels are in
tilted
mode. - maxGlyphCount number
When only a sub-set of data is available, ex. when paging. This property can be used to let the axis estimate how much space the labels will consume, allowing it to give a consistent space estimate over the entire dataset when paging.
- maxLengthPx number
Max length of labels in pixels
- minLengthPx number
Min length of labels in pixels. Labels will always at least require this much space
- mode string
Control how labels arrange themself. Availabe modes are
auto
,horizontal
,layered
andtilted
. When set toauto
the axis determines the best possible layout in the current context. - offset number
Offset in pixels along the axis direction.
- show boolean
Toggle labels on/off
- tiltAngle number
Tilting angle in degrees. Capped between -90 and 90. Only applicable when labels are in
tilted
mode. - tiltThreshold number
Threshold for toggle of tilted labels. Capped between 0 and 1. For example, if it is set to 0.7, then tilted labels will be toggled if less than 70% of the labels are visible.
-
- line objectRequired
line properties
- show boolean
Toggle line on/off
-
- paddingEnd number
Padding in direction perpendicular to the axis
- paddingStart number
Padding in direction perpendicular to the axis
- ticks objectRequired
ticks properties
- margin number
Space in pixels between the ticks and the line.
- show boolean
Toggle ticks on/off
- tickSize number
Size of the ticks in pixels.
-
DiscreteSettings
{
type: 'axis',
scale: '<name-of-band-scale>',
settings: {
labels: {
mode: 'tilted',
tiltAngle: 40,
},
},
}
Properties
- start stringRequired
Reference to the data property of the start value along the major axis
- end stringRequired
Reference to the data property of the end value along the major axis
Properties
- type 'bar'Required
Name of strategy
- settings objectRequired
Bars strategy settings
settings properties
- direction string | function
The direction in which the bars are growing: 'up', 'down', 'right' or 'left'.
- orientation string
Orientation of text: 'auto', 'horizontal' or 'vertical'
- fontFamily string
- fontSize number
- labels Array< object >Required
-
Properties
- type 'rows'Required
Name of strategy
- settings objectRequired
Rows strategy settings
settings properties
- fontFamily string
- fontSize number
- justify number
- padding number
- labels Array< object >Required
-
Properties
- type 'slice'Required
Name of strategy
- settings objectRequired
Slices strategy settings
settings properties
- direction string | function
The direction of the text: 'horizontal' or 'rotate'.
- fontFamily string
- fontSize number
- labels Array< object >Required
-
Properties
- component stringRequired
Key of target component
- selector stringRequired
Shape selector
- strategy BarsLabelStrategy | RowsLabelStrategy | SlicesLabelStrategyRequired
Strategy settings
Callback function for layer sort
Parameters
- a objectRequired
a properties
- id stringRequired
- data Array< DatumExtract >Required
-
- b objectRequired
b properties
- id stringRequired
- data Array< DatumExtract >Required
-
Properties
- fill string
Fill color
- stroke string
Stroke
- strokeWidth number
Stroke width
- opacity number
Opacity
Properties
- text string
Text (if applicable)
- fontSize string
Font size (if applicable)
- fontFamily string
Font family
- fill string
Fill color
- stroke string
Stroke
- strokeWidth number
Stroke width
- strokeDasharray string
Stroke dash array
- opacity number
Opacity
Properties
- value number | functionRequired
The value of the reference line. If a scale is specified, it is applied.
- scale string
Scale to use (if undefined will use normalized value 0-1)
- line GenericObject
The style of the line
- label LineLabel
The label style of the line
- slope number
The slope for the reference line
Properties
- padding numberRequired
Padding inside the label
- text string
Text
- fontSize string
Font size
- fontFamily string
Font family
- stroke string
Stroke
- strokeWidth number
Stroke width
- opacity number
Opacity
- align number | string
Alignment property left to right (0 = left, 1 = right). Also supports string ('left', 'center', 'middle', 'right')
- vAlign number | string
Alignment property top to bottom (0 = top, 1 = bottom). Also supports string ('top', 'center', 'middle', 'bottom')
- maxWidth number
The maximum relative width to the width of the rendering area (see maxWidthPx as well)
- maxWidthPx number
The maximum width in pixels. Labels will be rendered with the maximum size of the smallest value of maxWidth and maxWidthPx size, so you may specify maxWidth 0.8 but maxWidthPx 100 and will never be over 100px and never over 80% of the renderable area
- background LineLabelBackground
The background style (rect behind text)
- showValue boolean
Show value label
Properties
- fill string
Fill color
- stroke string
Stroke
- strokeWidth number
Stroke width
- opacity number
Opacity
Data extraction definition. Define how and what kind of data should be extracted from a DataSource
.
Properties
- source stringRequired
Which data source to extract from
- field stringRequired
The field to extract data from
- value ValueFn | string | number | boolean
The field value accessor
- label LabelFn | string | number | boolean
The field label accessor
- trackBy TrackByFn
Track by value accessor
- reduce ReduceFn | string
Reducer function
- reduceLabel ReduceLabelFn | string
Label reducer function
- filter FilterFn
Filter function
- props object
Additional properties to add to the extracted item
Extract
{
source: 'Products',
field: 'Product',
value: (val) => val,
label: (val) => `<${val}>`
props: {
year: { field: 'Year' }
num: { field: 'Sales' }
}
}
Callback function to filter the extracted data items
Parameters
- datum DatumExtractRequired
The extracted datum
Returns
- booleanRequired
Return true if the datum should be included in the final data set
Callback function to sort the extracted data items
Parameters
- Required
The extracted datum
- Required
The extracted datum
Returns
- numberRequired
If less than 0, sort a before b. If greater than 0, sort b before a
Callback function. Should return the key to stack by
Parameters
- datum DatumExtractRequired
The extracted datum
Returns
- anyRequired
The data value to stack by
Callback function. Should return the data value to stack with
Parameters
- datum DatumExtractRequired
The extracted datum
Returns
- anyRequired
The data value to stack with
Filter callback function
Parameters
- cell anyRequired
The field cell
Returns
- booleanRequired
Label callback function
Parameters
- cell anyRequired
The field cell
Returns
- stringRequired
Props
{
field: 'Sales',
value: (val) => Math.round(val),
label: (val) => `<${val}>`
}
Reduce callback function
Parameters
- values Array< any >Required
The collected values to reduce
Returns
- anyRequired
ReduceLabel callback function
Parameters
- labels Array< any >Required
The collected labels to reduce
- value anyRequired
Reduced value
Returns
- stringRequired
TrackBy callback function
Parameters
- cell anyRequired
The field cell
Returns
- anyRequired
Value callback function
Parameters
- cell anyRequired
The field cell
Returns
- anyRequired
Properties
- x number
x-coordinate
- y number
y-coordinate
- width number
Width
- height number
Height
- scaleRatio object
scaleRatio properties
- x number
Scale ratio on x-axis
- y number
Scale ratio on y-axis
-
- margin object
margin properties
- left number
Left margin
- top number
Top margin
-
An object containing width and height of the canvas buffer or a function returning an object on that format. Gets a rect object as input parameter.
A function which returns either (1) false (to specify no progressive rendering used) or an object specifing the data chunk rendered. This is only applied to a canvas renderer.
Returns
- ProgressiveObject | booleanRequired
Should return a transform object if transformation should be applied, otherwise undefined or a falsy value. Transforms can be applied with the canvas, svg and dom renderer. Transform is applied when running chart.update, see example. !Important: When a transform is applied to a component, the underlaying node representations are not updated with the new positions/sizes, which can cause problems for operations that relies on the positioning of the shapes/nodes (such as tooltips, selections etc). An extra chart update without a transform is therefore needed to make sure the node position information is in sync with the visual representation again.
Returns
- Required
TransformFunction
const pointComponentDef = {
type: 'point',
rendererSettings: {
tranform() {
if(shouldApplyTransform) {
return {
horizontalScaling: 1,
horizontalSkewing: 0,
verticalSkewing: 0,
verticalScaling: 1,
horizontalMoving: x,
verticalMoving: y
};
}
}
}
data: {
// ............
chart.update({ partialData: true });