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

Fix Time Point Data Sample Add Data Button #5328

Merged
merged 1 commit into from
Mar 13, 2018
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
27 changes: 8 additions & 19 deletions samples/scales/time/line-point-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down