require('./core/core.controller')(Chart);
require('./core/core.datasetController')(Chart);
require('./core/core.layoutService')(Chart);
-require('./core/core.legend')(Chart);
+require('./core/core.scaleService')(Chart);
require('./core/core.plugin.js')(Chart);
+require('./core/core.legend')(Chart);
require('./core/core.scale')(Chart);
-require('./core/core.scaleService')(Chart);
require('./core/core.title')(Chart);
require('./core/core.tooltip')(Chart);
Chart.layoutService.addBox(this, this.titleBlock);
}
-
- if (this.options.legend) {
- this.legend = new Chart.Legend({
- ctx: this.chart.ctx,
- options: this.options.legend,
- chart: this
- });
-
- Chart.layoutService.addBox(this, this.legend);
- }
},
updateLayout: function() {
}
});
+ // Register the legend plugin
+ Chart.pluginService.register({
+ beforeInit: function(chartInstance) {
+ var opts = chartInstance.options;
+ var legendOpts = opts.legend;
+
+ if (legendOpts) {
+ chartInstance.legend = new Chart.Legend({
+ ctx: chartInstance.chart.ctx,
+ options: legendOpts,
+ chart: chartInstance
+ });
+
+ Chart.layoutService.addBox(chartInstance, chartInstance.legend);
+ }
+ }
+ })
};