There are multiple levels of context objects:
-- `chart`
- - `dataset`
- - `data`
- - `scale`
- - `tick`
+* `chart`
+ * `dataset`
+ * `data`
+ * `scale`
+ * `tick`
Each level inherits its parent(s) and any contextual information stored in the parent is available through the child.
### chart
-- `chart`: the associated chart
-- `type`: `'chart'`
+* `chart`: the associated chart
+* `type`: `'chart'`
### dataset
In addition to [chart](#chart)
-- `active`: true if element is active (hovered)
-- `dataset`: dataset at index `datasetIndex`
-- `datasetIndex`: index of the current dataset
-- `index`: getter for `datasetIndex`
-- `type`: `'dataset'`
+* `active`: true if element is active (hovered)
+* `dataset`: dataset at index `datasetIndex`
+* `datasetIndex`: index of the current dataset
+* `index`: getter for `datasetIndex`
+* `type`: `'dataset'`
### data
In addition to [dataset](#dataset)
-- `active`: true if element is active (hovered)
-- `dataIndex`: index of the current data
-- `parsed`: the parsed data values for the given `dataIndex` and `datasetIndex`
-- `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
-- `element`: the element (point, arc, bar, etc.) for this data
-- `index`: getter for `dataIndex`
-- `type`: `'data'`
+* `active`: true if element is active (hovered)
+* `dataIndex`: index of the current data
+* `parsed`: the parsed data values for the given `dataIndex` and `datasetIndex`
+* `raw`: the raw data values for the given `dataIndex` and `datasetIndex`
+* `element`: the element (point, arc, bar, etc.) for this data
+* `index`: getter for `dataIndex`
+* `type`: `'data'`
### scale
In addition to [chart](#chart)
-- `scale`: the associated scale
-- `type`: `'scale'`
+* `scale`: the associated scale
+* `type`: `'scale'`
### tick
In addition to [scale](#scale)
-- `tick`: the associated tick object
-- `index`: tick index
-- `type`: `'tick'`
+* `tick`: the associated tick object
+* `index`: tick index
+* `type`: `'tick'`
ensureScalesHaveIDs() {
const options = this.options;
const scalesOptions = options.scales || {};
- const scaleOptions = options.scale;
each(scalesOptions, (axisOptions, axisID) => {
axisOptions.id = axisID;
});
-
- if (scaleOptions) {
- scaleOptions.id = scaleOptions.id || 'scale';
- }
}
/**
const me = this;
const options = me.options;
const scaleOpts = options.scales;
- const scales = me.scales || {};
+ const scales = me.scales;
const updated = Object.keys(scales).reduce((obj, id) => {
obj[id] = false;
return obj;
}
});
- me.scales = scales;
-
each(scales, (scale) => {
layouts.configure(me, scale, scale.options);
layouts.addBox(me, scale);
update(mode) {
const me = this;
- let i, ilen;
each(me.scales, (scale) => {
layouts.removeBox(me, scale);
me.notifyPlugins('beforeElementsUpdate');
// Make sure all dataset controllers have correct meta data counts
- for (i = 0, ilen = me.data.datasets.length; i < ilen; i++) {
+ for (let i = 0, ilen = me.data.datasets.length; i < ilen; i++) {
const {controller} = me.getDatasetMeta(i);
const reset = !animsDisabled && newControllers.indexOf(controller) === -1;
// New controllers will be reset after the layout pass, so we only want to modify
}
// Invoke onHover hook
- callCallback(options.onHover || options.hover.onHover, [e, active, me], me);
+ callCallback(options.onHover || hoverOptions.onHover, [e, active, me], me);
if (e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu') {
if (_isPointInArea(e, me.chartArea)) {