From ab5584c0b613b62056e82a02576626529d9d0274 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 6 May 2019 19:03:55 -0700 Subject: [PATCH] Cache scale --- src/controllers/controller.line.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index c671d657933..759db4c7e72 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -41,11 +41,13 @@ module.exports = DatasetController.extend({ var line = meta.dataset; var points = meta.data || []; var options = me.chart.options; - var scale = me.getScaleForId(meta.yAxisID); var dataset = me.getDataset(); var showLine = me._showLine = valueOrDefault(me._config.showLine, options.showLines); var i, ilen; + me._xScale = me.getScaleForId(meta.xAxisID); + me._yScale = me.getScaleForId(meta.yAxisID); + // Update Line if (showLine) { // Compatibility: If the properties are defined with only the old name, use those values @@ -54,7 +56,7 @@ module.exports = DatasetController.extend({ } // Utility - line._scale = scale; + line._scale = me._yScale; line._datasetIndex = me.index; // Data line._children = points; @@ -86,8 +88,8 @@ module.exports = DatasetController.extend({ var dataset = me.getDataset(); var datasetIndex = me.index; var value = dataset.data[index]; - var yScale = me.getScaleForId(meta.yAxisID); - var xScale = me.getScaleForId(meta.xAxisID); + var xScale = me._xScale; + var yScale = me._yScale; var lineModel = meta.dataset._model; var x, y; @@ -227,8 +229,7 @@ module.exports = DatasetController.extend({ calculatePointY: function(value, index, datasetIndex) { var me = this; var chart = me.chart; - var meta = me.getMeta(); - var yScale = me.getScaleForId(meta.yAxisID); + var yScale = me._yScale; var sumPos = 0; var sumNeg = 0; var i, ds, dsMeta;