From d541903c85e33431cd2e7195961ee28eb5528ab9 Mon Sep 17 00:00:00 2001 From: Simon Brunel Date: Sat, 25 Mar 2017 11:45:17 +0100 Subject: [PATCH] Move legend and title in the plugins folder --- src/chart.js | 8 +++++--- src/{core/core.legend.js => plugins/plugin.legend.js} | 5 ++--- src/{core/core.title.js => plugins/plugin.title.js} | 7 +++---- .../{core.legend.tests.js => plugin.legend.tests.js} | 0 test/specs/{core.title.tests.js => plugin.title.tests.js} | 0 5 files changed, 10 insertions(+), 10 deletions(-) rename src/{core/core.legend.js => plugins/plugin.legend.js} (99%) rename src/{core/core.title.js => plugins/plugin.title.js} (98%) rename test/specs/{core.legend.tests.js => plugin.legend.tests.js} (100%) rename test/specs/{core.title.tests.js => plugin.title.tests.js} (100%) diff --git a/src/chart.js b/src/chart.js index 591572110e8..4771b6d6562 100644 --- a/src/chart.js +++ b/src/chart.js @@ -15,8 +15,6 @@ require('./core/core.layoutService')(Chart); require('./core/core.scaleService')(Chart); require('./core/core.ticks.js')(Chart); require('./core/core.scale')(Chart); -require('./core/core.title')(Chart); -require('./core/core.legend')(Chart); require('./core/core.interaction')(Chart); require('./core/core.tooltip')(Chart); @@ -52,7 +50,11 @@ require('./charts/Chart.Scatter')(Chart); // Loading built-it plugins var plugins = []; -plugins.push(require('./plugins/plugin.filler.js')(Chart)); +plugins.push( + require('./plugins/plugin.filler.js')(Chart), + require('./plugins/plugin.legend.js')(Chart), + require('./plugins/plugin.title.js')(Chart) +); Chart.plugins.register(plugins); diff --git a/src/core/core.legend.js b/src/plugins/plugin.legend.js similarity index 99% rename from src/core/core.legend.js rename to src/plugins/plugin.legend.js index b68f1de1a9c..a2d21d0b625 100644 --- a/src/core/core.legend.js +++ b/src/plugins/plugin.legend.js @@ -507,8 +507,7 @@ module.exports = function(Chart) { Chart.layoutService.addBox(chart, legend); } - // Register the legend plugin - Chart.plugins.register({ + return { id: 'legend', beforeInit: function(chart) { @@ -541,5 +540,5 @@ module.exports = function(Chart) { legend.handleEvent(e); } } - }); + }; }; diff --git a/src/core/core.title.js b/src/plugins/plugin.title.js similarity index 98% rename from src/core/core.title.js rename to src/plugins/plugin.title.js index eb060082433..34490c16f90 100644 --- a/src/core/core.title.js +++ b/src/plugins/plugin.title.js @@ -3,6 +3,7 @@ module.exports = function(Chart) { var helpers = Chart.helpers; + var noop = helpers.noop; Chart.defaults.global.title = { display: false, @@ -16,7 +17,6 @@ module.exports = function(Chart) { text: '' }; - var noop = helpers.noop; Chart.Title = Chart.Element.extend({ initialize: function(config) { var me = this; @@ -195,8 +195,7 @@ module.exports = function(Chart) { Chart.layoutService.addBox(chart, title); } - // Register the title plugin - Chart.plugins.register({ + return { id: 'title', beforeInit: function(chart) { @@ -223,5 +222,5 @@ module.exports = function(Chart) { delete chart.titleBlock; } } - }); + }; }; diff --git a/test/specs/core.legend.tests.js b/test/specs/plugin.legend.tests.js similarity index 100% rename from test/specs/core.legend.tests.js rename to test/specs/plugin.legend.tests.js diff --git a/test/specs/core.title.tests.js b/test/specs/plugin.title.tests.js similarity index 100% rename from test/specs/core.title.tests.js rename to test/specs/plugin.title.tests.js