mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 16:26:52 +01:00
Make Chart.defaults/Ticks/Interaction importable (#4512)
Default options can now be accessed by importing `core/core.defaults`. The returned object acts as a singleton and is populated when importing classes that expose their own default values (meaning that importing only `code.defaults` results in an empty object). Also make `Chart.Ticks` and `Chart.Interaction` importable since existing defaults rely on these values. Add the `defaults._set` method that make easier declaring new defaults by merging given values with existing ones for a specific scope (`global`, `scale`, `bar`, etc).
This commit is contained in:
@@ -1,41 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var defaults = require('../core/core.defaults');
|
||||
var helpers = require('../helpers/index');
|
||||
|
||||
module.exports = function(Chart) {
|
||||
defaults._set('bubble', {
|
||||
hover: {
|
||||
mode: 'single'
|
||||
},
|
||||
|
||||
Chart.defaults.bubble = {
|
||||
hover: {
|
||||
mode: 'single'
|
||||
},
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'linear', // bubble should probably use a linear scale by default
|
||||
position: 'bottom',
|
||||
id: 'x-axis-0' // need an ID so datasets can reference the scale
|
||||
}],
|
||||
yAxes: [{
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
id: 'y-axis-0'
|
||||
}]
|
||||
},
|
||||
|
||||
scales: {
|
||||
xAxes: [{
|
||||
type: 'linear', // bubble should probably use a linear scale by default
|
||||
position: 'bottom',
|
||||
id: 'x-axis-0' // need an ID so datasets can reference the scale
|
||||
}],
|
||||
yAxes: [{
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
id: 'y-axis-0'
|
||||
}]
|
||||
},
|
||||
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function() {
|
||||
// Title doesn't make sense for scatter since we format the data as a point
|
||||
return '';
|
||||
},
|
||||
label: function(tooltipItem, data) {
|
||||
var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
|
||||
var dataPoint = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
|
||||
return datasetLabel + ': (' + tooltipItem.xLabel + ', ' + tooltipItem.yLabel + ', ' + dataPoint.r + ')';
|
||||
}
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
title: function() {
|
||||
// Title doesn't make sense for scatter since we format the data as a point
|
||||
return '';
|
||||
},
|
||||
label: function(item, data) {
|
||||
var datasetLabel = data.datasets[item.datasetIndex].label || '';
|
||||
var dataPoint = data.datasets[item.datasetIndex].data[item.index];
|
||||
return datasetLabel + ': (' + item.xLabel + ', ' + item.yLabel + ', ' + dataPoint.r + ')';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = function(Chart) {
|
||||
|
||||
Chart.controllers.bubble = Chart.DatasetController.extend({
|
||||
|
||||
|
||||
Reference in New Issue
Block a user