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.datasets[type].*
-- or globally: Chart.defaults.datasets[type].*
+- per chart: options[type].datasets.*
+- or globally: Chart.defaults[type].datasets.*
where type corresponds to the dataset type.
// It looks like a bug exists when the defaults don't exist
Chart.defaults.derivedBubble = Chart.defaults.bubble;
-// Sets the default dataset config for 'derivedBubble' to be the same as the bubble dataset defaults.
-// It looks like a bug exists when the dataset defaults don't exist
-Chart.defaults.datasets.derivedBubble = Chart.defaults.datasets.bubble;
-
// I think the recommend using Chart.controllers.bubble.extend({ extensions here });
var custom = Chart.controllers.bubble.extend({
draw: function(ease) {
### Options
+* Dataset options are now configured as `options[type].datasets` rather than `options.datasets[type]`
* `Polar area` `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`.
* `scales.[x/y]Axes` arrays were removed. Scales are now configured directly to `options.scales` object with the object key being the scale Id.
* `scales.[x/y]Axes.barPercentage` was moved to dataset option `barPercentage`
mode: 'index'
},
+ datasets: {
+ categoryPercentage: 0.8,
+ barPercentage: 0.9,
+ animation: {
+ numbers: {
+ type: 'number',
+ properties: ['x', 'y', 'base', 'width', 'height']
+ }
+ }
+ },
+
scales: {
x: {
type: 'category',
}
});
-defaults._set('datasets', {
- bar: {
- categoryPercentage: 0.8,
- barPercentage: 0.9,
- animation: {
- numbers: {
- type: 'number',
- properties: ['x', 'y', 'base', 'width', 'height']
- }
- }
- }
-});
-
/**
* Computes the "optimal" sample size to maintain bars equally sized while preventing overlap.
* @private
}
},
+ datasets: {
+ categoryPercentage: 0.8,
+ barPercentage: 0.9
+ },
+
elements: {
rectangle: {
borderSkipped: 'left'
}
});
-defaults._set('datasets', {
- horizontalBar: {
- categoryPercentage: 0.8,
- barPercentage: 0.9
- }
-});
-
export default BarController.extend({
/**
* @private
}
},
+ datasets: {
+ showLine: false
+ },
+
tooltips: {
callbacks: {
title: function() {
}
});
-defaults._set('datasets', {
- scatter: {
- showLine: false
- }
-});
-
// Scatter charts use line controllers
export default LineController;
_configure: function() {
const me = this;
me._config = helpers.merge({}, [
- me.chart.options.datasets[me._type],
+ me.chart.options[me._type].datasets,
me.getDataset(),
], {
merger: function(key, target, source) {
"responsive": false,
"legend": false,
"title": false,
- "datasets": {
- "bar": {
+ "bar": {
+ "datasets": {
"barPercentage": 1,
"categoryPercentage": 1
}
"responsive": false,
"legend": false,
"title": false,
- "datasets": {
- "bar": {
+ "bar": {
+ "datasets": {
"barPercentage": 1,
"categoryPercentage": 1
}
"responsive": false,
"legend": false,
"title": false,
- "datasets": {
- "bar": {
+ "bar": {
+ "datasets": {
"barPercentage": 1,
"categoryPercentage": 1
}
"responsive": false,
"legend": false,
"title": false,
- "datasets": {
- "bar": {
+ "bar": {
+ "datasets": {
"barPercentage": 1,
"categoryPercentage": 1
}
"responsive": false,
"legend": false,
"title": false,
- "datasets": {
- "bar": {
+ "bar": {
+ "datasets": {
"barPercentage": 1,
"categoryPercentage": 1
}
options: {
legend: false,
title: false,
- datasets: {
- bar: {
+ bar: {
+ datasets: {
barPercentage: 1,
}
},
options: {
legend: false,
title: false,
- datasets: {
- bar: {
+ bar: {
+ datasets: {
barPercentage: 1,
}
},
responsive: false,
legend: false,
title: false,
- datasets: {
- line: {
+ line: {
+ datasets: {
lineTension: 0.4,
borderWidth: 1,
pointRadius: 1.5,
var chart = window.acquireChart(this.config);
var meta = chart.getDatasetMeta(0);
var xScale = chart.scales[meta.xAxisID];
- var options = Chart.defaults.datasets.bar;
+ var options = Chart.defaults.bar.datasets;
var categoryPercentage = options.categoryPercentage;
var barPercentage = options.barPercentage;
options: {
legend: false,
title: false,
- datasets: {
- bar: {
+ bar: {
+ datasets: {
barThickness: barThickness
}
},
expected = barThickness;
} else {
var scale = chart.scales.x;
- var options = Chart.defaults.datasets.bar;
+ var options = Chart.defaults.bar.datasets;
var categoryPercentage = options.categoryPercentage;
var barPercentage = options.barPercentage;
var tickInterval = scale.getPixelForTick(1) - scale.getPixelForTick(0);
describe('dataset global defaults', function() {
beforeEach(function() {
- this._defaults = Chart.helpers.clone(Chart.defaults.datasets.line);
+ this._defaults = Chart.helpers.clone(Chart.defaults.line.datasets);
});
afterEach(function() {
- Chart.defaults.datasets.line = this._defaults;
+ Chart.defaults.line.datasets = this._defaults;
delete this._defaults;
});
it('should utilize the dataset global default options', function() {
- Chart.defaults.datasets.line = Chart.defaults.datasets.line || {};
+ Chart.defaults.line.datasets = Chart.defaults.line.datasets || {};
- Chart.helpers.merge(Chart.defaults.datasets.line, {
+ Chart.helpers.merge(Chart.defaults.line.datasets, {
spanGaps: true,
lineTension: 0.231,
backgroundColor: '#add',
});
it('should be overriden by user-supplied values', function() {
- Chart.defaults.datasets.line = Chart.defaults.datasets.line || {};
+ Chart.defaults.line.datasets = Chart.defaults.line.datasets || {};
- Chart.helpers.merge(Chart.defaults.datasets.line, {
+ Chart.helpers.merge(Chart.defaults.line.datasets, {
spanGaps: true,
lineTension: 0.231
});
labels: ['label1', 'label2']
},
options: {
- datasets: {
- line: {
+ line: {
+ datasets: {
lineTension: 0.345,
backgroundColor: '#add'
}
labels: ['label1', 'label2']
},
options: {
- datasets: {
- line: {
+ line: {
+ datasets: {
spanGaps: true,
lineTension: 0.231,
backgroundColor: '#add',