Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Chart.plugins importable #5114

Merged
merged 1 commit into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions src/chart.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading