mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-21 07:36:52 +01:00
Make Chart.controllers.* importable (#5871)
`controllers.*.js` and `core.datasetController.js` are now importable (no more function export), that's why there is so many changes mainly due to one indentation level removed. Split code for `bar/horizontalBar` and `doughnut/pie` in separate files, added a global controllers import (`src/controllers/index.js`) and add tests to check that all dataset controllers are correctly registered under `chart.controllers.{type}`.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
var Animation = require('./core.animation');
|
||||
var animations = require('./core.animations');
|
||||
var controllers = require('../controllers/index');
|
||||
var defaults = require('./core.defaults');
|
||||
var helpers = require('../helpers/index');
|
||||
var Interaction = require('./core.interaction');
|
||||
@@ -20,9 +21,6 @@ module.exports = function(Chart) {
|
||||
// Destroy method on the chart will remove the instance of the chart from this reference.
|
||||
Chart.instances = {};
|
||||
|
||||
// Controllers available for dataset visualization eg. bar, line, slice, etc.
|
||||
Chart.controllers = {};
|
||||
|
||||
/**
|
||||
* Initializes the given config with global and chart default values.
|
||||
*/
|
||||
@@ -337,7 +335,7 @@ module.exports = function(Chart) {
|
||||
meta.controller.updateIndex(datasetIndex);
|
||||
meta.controller.linkScales();
|
||||
} else {
|
||||
var ControllerClass = Chart.controllers[meta.type];
|
||||
var ControllerClass = controllers[meta.type];
|
||||
if (ControllerClass === undefined) {
|
||||
throw new Error('"' + meta.type + '" is not a chart type.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user