From ce22a8ae8b3612854a537e3f449db05c0ee34446 Mon Sep 17 00:00:00 2001 From: etimberg Date: Sat, 10 Mar 2018 12:38:43 -0500 Subject: [PATCH] Time Point Data sample works correctly --- samples/scales/time/line-point-data.html | 27 +++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/samples/scales/time/line-point-data.html b/samples/scales/time/line-point-data.html index e18be91f3d8..604a49b4f1a 100644 --- a/samples/scales/time/line-point-data.html +++ b/samples/scales/time/line-point-data.html @@ -121,27 +121,16 @@ window.myLine.update(); }); - - // TODO : fix issue with addData - // See https://github.com/chartjs/Chart.js/issues/5197 - // The Add Data button for this sample has no effect. - // An error is logged in the console. document.getElementById('addData').addEventListener('click', function() { if (config.data.datasets.length > 0) { - var numTicks = window.myLine.scales['x-axis-0'].ticksAsTimestamps.length; - var lastTime = numTicks ? moment(window.myLine.scales['x-axis-0'].ticksAsTimestamps[numTicks - 1]) : moment(); - - var newTime = lastTime - .clone() - .add(1, 'day') - .format('MM/DD/YYYY HH:mm'); - - for (var index = 0; index < config.data.datasets.length; ++index) { - config.data.datasets[index].data.push({ - x: newTime, - y: randomScalingFactor() - }); - } + config.data.datasets[0].data.push({ + x: newDateString(config.data.datasets[0].data.length + 2), + y: randomScalingFactor() + }); + config.data.datasets[1].data.push({ + x: newDate(config.data.datasets[1].data.length + 2), + y: randomScalingFactor() + }); window.myLine.update(); }