From: Jukka Kurkela Date: Wed, 10 Feb 2021 16:06:48 +0000 (+0200) Subject: Small chores (#8408) X-Git-Tag: v3.0.0-beta.11~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6de5b3fa9ed3ea2af376f71eb8a9da392fa2915e;p=thirdparty%2FChart.js.git Small chores (#8408) --- diff --git a/.editorconfig b/.editorconfig index a992ef391..a56f2d2d2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/docs/docs/general/options.md b/docs/docs/general/options.md index d0e54ac5e..777613853 100644 --- a/docs/docs/general/options.md +++ b/docs/docs/general/options.md @@ -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'` diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index d322e70a3..0ce190395 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -152,9 +152,7 @@ PolarAreaController.defaults = { animateScale: true }, aspectRatio: 1, - datasets: { - indexAxis: 'r' - }, + indexAxis: 'r', scales: { r: { type: 'radialLinear', diff --git a/src/controllers/controller.radar.js b/src/controllers/controller.radar.js index e197f3282..a2b8a2b12 100644 --- a/src/controllers/controller.radar.js +++ b/src/controllers/controller.radar.js @@ -129,9 +129,7 @@ RadarController.defaults = { type: 'radialLinear', } }, - datasets: { - indexAxis: 'r' - }, + indexAxis: 'r', elements: { line: { fill: 'start', diff --git a/src/core/core.controller.js b/src/core/core.controller.js index cf0b75867..04ec4c191 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -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)) {