Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache getScaleForId() calls in the line controller #6250

Merged
merged 1 commit into from
May 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/controllers/controller.line.js
Original file line number Diff line number Diff line change
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;
kurkle marked this conversation as resolved.
Show resolved Hide resolved
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