In src/core/core.controller.js: we have some code that updates each controller twice. Both the call to helpers.each and updateDatasets below end up calling controller.update on every controller.
// Can only reset the new controllers after the scales have been updated
helpers.each(newControllers, function(controller) {
controller.reset();
});
me.updateDatasets();
The source for controller.reset calls controller.update:
reset: function() {
this.update(true);
},
And updateDatasets calls updateDataset which calls controller.update:
updateDatasets: function() {
var me = this;
if (plugins.notify(me, 'beforeDatasetsUpdate') === false) {
return;
}
for (var i = 0, ilen = me.data.datasets.length; i < ilen; ++i) {
me.updateDataset(i);
}
plugins.notify(me, 'afterDatasetsUpdate');
},
updateDataset: function(index) {
var me = this;
var meta = me.getDatasetMeta(index);
var args = {
meta: meta,
index: index
};
if (plugins.notify(me, 'beforeDatasetUpdate', [args]) === false) {
return;
}
meta.controller.update();
plugins.notify(me, 'afterDatasetUpdate', [args]);
},
So we end up calling controller.update twice in a row every time we update a chart, which seems like a fairly expensive operation to duplicate. I'm wondering if we can improve performance by removing one of these.
In
src/core/core.controller.js:we have some code that updates each controller twice. Both the call tohelpers.eachandupdateDatasetsbelow end up callingcontroller.updateon every controller.The source for
controller.resetcallscontroller.update:And
updateDatasetscallsupdateDatasetwhich callscontroller.update:So we end up calling
controller.updatetwice in a row every time we update a chart, which seems like a fairly expensive operation to duplicate. I'm wondering if we can improve performance by removing one of these.