From: Jukka Kurkela Date: Tue, 24 Nov 2020 20:27:51 +0000 (+0200) Subject: Restore `datasets` namespace (revert 6955) (#8090) X-Git-Tag: v3.0.0-beta.7~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3ad31893d1359d059f5e669d974aa939d9bb224;p=thirdparty%2FChart.js.git Restore `datasets` namespace (revert 6955) (#8090) --- diff --git a/docs/docs/configuration/index.md b/docs/docs/configuration/index.md index 3b20c090f..68f161fe1 100644 --- a/docs/docs/configuration/index.md +++ b/docs/docs/configuration/index.md @@ -39,7 +39,7 @@ var chartDifferentHoverMode = new Chart(ctx, { Options may be configured directly on the dataset. The dataset options can be changed at 3 different levels and are evaluated with the following priority: - per dataset: dataset.* -- per chart: options[type].datasets.* +- per chart: options.datasets[type].* - or globally: Chart.defaults.controllers[type].datasets.* where type corresponds to the dataset type. diff --git a/docs/docs/getting-started/v3-migration.md b/docs/docs/getting-started/v3-migration.md index f7d59f301..4e8c08d7b 100644 --- a/docs/docs/getting-started/v3-migration.md +++ b/docs/docs/getting-started/v3-migration.md @@ -91,7 +91,6 @@ A number of changes were made to the configuration options passed to the `Chart` * `scales.[x/y]Axes.zeroLine*` options of axes were removed. Use scriptable scale options instead. * The dataset option `steppedLine` was removed. Use `stepped` * The chart option `showLines` was renamed to `showLine` to match the dataset option. -* Dataset options are now configured as `options[type].datasets` rather than `options.datasets[type]` * To override the platform class used in a chart instance, pass `platform: PlatformClass` in the config object. Note that the class should be passed, not an instance of the class. * `aspectRatio` defaults to 1 for doughnut, pie, polarArea, and radar charts * `TimeScale` does not read `t` from object data by default anymore. The default property is `x` or `y`, depending on the orientation. See [data structures](../general/data-structures.md) for details on how to change the default. diff --git a/src/core/core.config.js b/src/core/core.config.js index 2f0c1dd89..b84361537 100644 --- a/src/core/core.config.js +++ b/src/core/core.config.js @@ -4,9 +4,9 @@ import {mergeIf, merge, _merger} from '../helpers/helpers.core'; export function getIndexAxis(type, options) { const typeDefaults = defaults.controllers[type] || {}; const datasetDefaults = typeDefaults.datasets || {}; - const typeOptions = options[type] || {}; - const datasetOptions = typeOptions.datasets || {}; - return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x'; + const datasetOptions = options.datasets || {}; + const typeOptions = datasetOptions[type] || {}; + return typeOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x'; } function getAxisFromDefaultScaleID(id, indexAxis) { diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index d7bfab12b..bbd98de47 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -396,7 +396,7 @@ export default class DatasetController { const me = this; me._config = merge(Object.create(null), [ defaults.controllers[me._type].datasets, - (me.chart.options[me._type] || {}).datasets, + (me.chart.options.datasets || {})[me._type], me.getDataset(), ], { merger(key, target, source) { diff --git a/test/fixtures/controller.bar/bar-thickness-multiple.json b/test/fixtures/controller.bar/bar-thickness-multiple.json index 3cf2e7df6..d9e77a28d 100644 --- a/test/fixtures/controller.bar/bar-thickness-multiple.json +++ b/test/fixtures/controller.bar/bar-thickness-multiple.json @@ -16,8 +16,8 @@ }, "options": { "responsive": false, - "bar": { - "datasets": { + "datasets": { + "bar": { "barPercentage": 1, "categoryPercentage": 1 } diff --git a/test/fixtures/controller.bar/bar-thickness-no-overlap.json b/test/fixtures/controller.bar/bar-thickness-no-overlap.json index 0849b850c..c3e21c04d 100644 --- a/test/fixtures/controller.bar/bar-thickness-no-overlap.json +++ b/test/fixtures/controller.bar/bar-thickness-no-overlap.json @@ -16,8 +16,8 @@ }, "options": { "responsive": false, - "bar": { - "datasets": { + "datasets": { + "bar": { "barPercentage": 1, "categoryPercentage": 1 } diff --git a/test/fixtures/controller.bar/bar-thickness-offset.json b/test/fixtures/controller.bar/bar-thickness-offset.json index 574f3abb6..7fee66509 100644 --- a/test/fixtures/controller.bar/bar-thickness-offset.json +++ b/test/fixtures/controller.bar/bar-thickness-offset.json @@ -16,8 +16,8 @@ }, "options": { "responsive": false, - "bar": { - "datasets": { + "datasets": { + "bar": { "barPercentage": 1, "categoryPercentage": 1 } diff --git a/test/fixtures/controller.bar/bar-thickness-reverse.json b/test/fixtures/controller.bar/bar-thickness-reverse.json index 6ae340f83..eb004a27f 100644 --- a/test/fixtures/controller.bar/bar-thickness-reverse.json +++ b/test/fixtures/controller.bar/bar-thickness-reverse.json @@ -16,8 +16,8 @@ }, "options": { "responsive": false, - "bar": { - "datasets": { + "datasets": { + "bar": { "barPercentage": 1, "categoryPercentage": 1 } diff --git a/test/fixtures/controller.bar/bar-thickness-stacked.json b/test/fixtures/controller.bar/bar-thickness-stacked.json index ddf4ff868..807e964a4 100644 --- a/test/fixtures/controller.bar/bar-thickness-stacked.json +++ b/test/fixtures/controller.bar/bar-thickness-stacked.json @@ -16,8 +16,8 @@ }, "options": { "responsive": false, - "bar": { - "datasets": { + "datasets": { + "bar": { "barPercentage": 1, "categoryPercentage": 1 } diff --git a/test/fixtures/controller.bar/stacking/logarithmic-strings.js b/test/fixtures/controller.bar/stacking/logarithmic-strings.js index aa92af956..43763f67a 100644 --- a/test/fixtures/controller.bar/stacking/logarithmic-strings.js +++ b/test/fixtures/controller.bar/stacking/logarithmic-strings.js @@ -12,8 +12,8 @@ module.exports = { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - bar: { - datasets: { + datasets: { + bar: { barPercentage: 1, } }, diff --git a/test/fixtures/controller.bar/stacking/logarithmic.js b/test/fixtures/controller.bar/stacking/logarithmic.js index 9e594c277..a18911fed 100644 --- a/test/fixtures/controller.bar/stacking/logarithmic.js +++ b/test/fixtures/controller.bar/stacking/logarithmic.js @@ -12,8 +12,8 @@ module.exports = { labels: ['label1', 'label2', 'label3', 'label4'] }, options: { - bar: { - datasets: { + datasets: { + bar: { barPercentage: 1, } }, diff --git a/test/fixtures/plugin.filler/fill-line-dataset-interpolated.js b/test/fixtures/plugin.filler/fill-line-dataset-interpolated.js index 899da0a23..c2cbc845a 100644 --- a/test/fixtures/plugin.filler/fill-line-dataset-interpolated.js +++ b/test/fixtures/plugin.filler/fill-line-dataset-interpolated.js @@ -39,8 +39,8 @@ module.exports = { options: { animation: false, responsive: false, - line: { - datasets: { + datasets: { + line: { tension: 0.4, borderWidth: 1, pointRadius: 1.5, diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 6cbd36782..47ab800b9 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1436,8 +1436,8 @@ describe('Chart.controllers.bar', function() { options: { legend: false, title: false, - bar: { - datasets: { + datasets: { + bar: { barThickness: barThickness } }, diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index fa2e87eb1..004dc4a6c 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -570,8 +570,8 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2'] }, options: { - line: { - datasets: { + datasets: { + line: { tension: 0.345, backgroundColor: '#add' } @@ -601,8 +601,8 @@ describe('Chart.controllers.line', function() { labels: ['label1', 'label2'] }, options: { - line: { - datasets: { + datasets: { + line: { spanGaps: true, tension: 0.231, backgroundColor: '#add',