mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Small chores (#8408)
This commit is contained in:
parent
a8329e4f13
commit
6de5b3fa9e
@ -2,21 +2,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.mdx]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
@ -41,11 +41,11 @@ The object is preserved, so it can be used to store and pass information between
|
||||
|
||||
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.
|
||||
|
||||
@ -53,42 +53,42 @@ The context object contains the following properties:
|
||||
|
||||
### 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'`
|
||||
|
||||
@ -152,9 +152,7 @@ PolarAreaController.defaults = {
|
||||
animateScale: true
|
||||
},
|
||||
aspectRatio: 1,
|
||||
datasets: {
|
||||
indexAxis: 'r'
|
||||
},
|
||||
indexAxis: 'r',
|
||||
scales: {
|
||||
r: {
|
||||
type: 'radialLinear',
|
||||
|
||||
@ -129,9 +129,7 @@ RadarController.defaults = {
|
||||
type: 'radialLinear',
|
||||
}
|
||||
},
|
||||
datasets: {
|
||||
indexAxis: 'r'
|
||||
},
|
||||
indexAxis: 'r',
|
||||
elements: {
|
||||
line: {
|
||||
fill: 'start',
|
||||
|
||||
@ -238,15 +238,10 @@ class Chart {
|
||||
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';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,7 +251,7 @@ class Chart {
|
||||
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;
|
||||
@ -313,8 +308,6 @@ class Chart {
|
||||
}
|
||||
});
|
||||
|
||||
me.scales = scales;
|
||||
|
||||
each(scales, (scale) => {
|
||||
layouts.configure(me, scale, scale.options);
|
||||
layouts.addBox(me, scale);
|
||||
@ -435,7 +428,6 @@ class Chart {
|
||||
|
||||
update(mode) {
|
||||
const me = this;
|
||||
let i, ilen;
|
||||
|
||||
each(me.scales, (scale) => {
|
||||
layouts.removeBox(me, scale);
|
||||
@ -462,7 +454,7 @@ class Chart {
|
||||
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
|
||||
@ -1078,7 +1070,7 @@ class Chart {
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user