Skip to content

Commit

Permalink
Make Chart.plugins importable (#5114)
Browse files Browse the repository at this point in the history
Explicitly deprecate (since 2.1.5) `Chart.Legend` and `Chart.Title`.
  • Loading branch information
simonbrunel committed Jan 8, 2018
1 parent ce27fe5 commit fb3ea03
Show file tree
Hide file tree
Showing 11 changed files with 1,316 additions and 1,276 deletions.
54 changes: 44 additions & 10 deletions src/chart.js
Expand Up @@ -14,9 +14,9 @@ Chart.elements = require('./elements/index');
Chart.Interaction = require('./core/core.interaction');
Chart.layout = require('./core/core.layout');
Chart.platform = require('./platforms/platform');
Chart.plugins = require('./core/core.plugins');
Chart.Ticks = require('./core/core.ticks');

require('./core/core.plugin')(Chart);
require('./core/core.animation')(Chart);
require('./core/core.controller')(Chart);
require('./core/core.datasetController')(Chart);
Expand Down Expand Up @@ -50,15 +50,12 @@ require('./charts/Chart.Radar')(Chart);
require('./charts/Chart.Scatter')(Chart);

// Loading built-it plugins
var plugins = [];

plugins.push(
require('./plugins/plugin.filler')(Chart),
require('./plugins/plugin.legend')(Chart),
require('./plugins/plugin.title')(Chart)
);

Chart.plugins.register(plugins);
var plugins = require('./plugins');
for (var k in plugins) {
if (plugins.hasOwnProperty(k)) {
Chart.plugins.register(plugins[k]);
}
}

Chart.platform.initialize();

Expand All @@ -69,6 +66,43 @@ if (typeof window !== 'undefined') {

// DEPRECATIONS

/**
* Provided for backward compatibility, not available anymore
* @namespace Chart.Legend
* @deprecated since version 2.1.5
* @todo remove at version 3
* @private
*/
Chart.Legend = plugins.legend._element;

/**
* Provided for backward compatibility, not available anymore
* @namespace Chart.Title
* @deprecated since version 2.1.5
* @todo remove at version 3
* @private
*/
Chart.Title = plugins.title._element;

/**
* Provided for backward compatibility, use Chart.plugins instead
* @namespace Chart.pluginService
* @deprecated since version 2.1.5
* @todo remove at version 3
* @private
*/
Chart.pluginService = Chart.plugins;

/**
* Provided for backward compatibility, inheriting from Chart.PlugingBase has no
* effect, instead simply create/register plugins via plain JavaScript objects.
* @interface Chart.PluginBase
* @deprecated since version 2.5.0
* @todo remove at version 3
* @private
*/
Chart.PluginBase = Chart.Element.extend({});

/**
* Provided for backward compatibility, use Chart.helpers.canvas instead.
* @namespace Chart.canvasHelpers
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.controller.js
Expand Up @@ -5,9 +5,9 @@ var helpers = require('../helpers/index');
var Interaction = require('./core.interaction');
var layout = require('./core.layout');
var platform = require('../platforms/platform');
var plugins = require('./core.plugins');

module.exports = function(Chart) {
var plugins = Chart.plugins;

// Create a dictionary of chart types, to allow for extension of existing types
Chart.types = {};
Expand Down

0 comments on commit fb3ea03

Please sign in to comment.