From 76ef7de64697ec51d49737bfbe9e45fe0b4e0953 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 21 Jan 2016 21:32:59 -0500 Subject: [PATCH 1/2] Fix sample file addData button --- samples/timeScale/combo-time-scale.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/timeScale/combo-time-scale.html b/samples/timeScale/combo-time-scale.html index 76f1b49fb..86657cdee 100644 --- a/samples/timeScale/combo-time-scale.html +++ b/samples/timeScale/combo-time-scale.html @@ -74,6 +74,7 @@ }, ] }, options: { + showLines: true, responsive: true, scales: { xAxes: [{ @@ -144,10 +145,7 @@ $('#addData').click(function() { if (config.data.datasets.length > 0) { - config.data.labels.push( - myLine.scales['x-axis-0'].labelMoments[myLine.scales['x-axis-0'].labelMoments.length - 1].add(1, 'day') - .format('MM/DD/YYYY') - ); + config.data.labels.push(newDateString(config.data.labels.length)); for (var index = 0; index < config.data.datasets.length; ++index) { config.data.datasets[index].data.push(randomScalingFactor()); From 59e3ccb42a5af0ae7b8176cc6d80f63a1082f3de Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Thu, 21 Jan 2016 22:00:21 -0500 Subject: [PATCH 2/2] buildOrUpdateControllers now returns an array of all the new controllers that were created. Build controllers before updating the scales but only reset them afterwards because the scales need to update label moments first. --- src/core/core.controller.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index 654964c0b..b0e1b08f7 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -208,8 +208,10 @@ Chart.layoutService.update(this, this.chart.width, this.chart.height); }, - buildOrUpdateControllers: function buildOrUpdateControllers(resetNewControllers) { + buildOrUpdateControllers: function buildOrUpdateControllers() { var types = []; + var newControllers = []; + helpers.each(this.data.datasets, function(dataset, datasetIndex) { if (!dataset.type) { dataset.type = this.config.type; @@ -222,10 +224,7 @@ dataset.controller.updateIndex(datasetIndex); } else { dataset.controller = new Chart.controllers[type](this, datasetIndex); - - if (resetNewControllers) { - dataset.controller.reset(); - } + newControllers.push(dataset.controller); } }, this); @@ -237,6 +236,8 @@ } } } + + return newControllers; }, resetElements: function resetElements() { @@ -250,10 +251,15 @@ this.tooltip._data = this.data; // Make sure dataset controllers are updated and new controllers are reset - this.buildOrUpdateControllers(true); + var newControllers = this.buildOrUpdateControllers(); Chart.layoutService.update(this, this.chart.width, this.chart.height); + // Can only reset the new controllers after the scales have been updated + helpers.each(newControllers, function(controller) { + controller.reset(); + }); + // Make sure all dataset controllers have correct meta data counts helpers.each(this.data.datasets, function(dataset, datasetIndex) { dataset.controller.buildOrUpdateElements();