Skip to content

Commit

Permalink
Cache getScaleForId() calls in the line controller (chartjs#6250)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and simonbrunel committed May 8, 2019
1 parent b88f522 commit fb7e8ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/controllers/controller.line.js
Expand Up @@ -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
Expand All @@ -54,7 +56,7 @@ module.exports = DatasetController.extend({
}

// Utility
line._scale = scale;
line._scale = me._yScale;
line._datasetIndex = me.index;
// Data
line._children = points;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit fb7e8ae

Please sign in to comment.