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
Exception when same params object is used to call MG.data_graphic multiple times #401
Comments
Don't you get that error irrespective of var data = [];
for (var i = 0; i < 100; i++) {
data.push({
date: i,
value: Math.random() * (100 - 0) + 0
})
}
MG.data_graphic({
description: 'New data is shown as it comes in',
title: 'Realtime updates',
data: data,
max_y: 120,
xax_start_at_min: true,
transition_on_update: true,
y_extended_ticks: true,
interpolate: 'linear',
target: '.result'
}); |
No, I tracked it down to flipping the sax_start_at_min option. I put together the logic in a minimal form for the interactive demo:
Interestingly enough this fails regardless of |
This may well be related to #393, which I'm currently looking at. Using the same params object on multiple calls to MG.data_graphic appears to be the culprit. Add this right before your penultimate line (i.e. delete options.xax_format; |
This helps with the minimal example. The issue persists for the angular-directive as I already worked around this issue by deep copying the options before invoking |
With the change that I just committed, this slightly modified block now works for me. Would you mind verifying, please. var data = [];
var options = {
description: 'New data is shown as it comes in',
title: 'Realtime updates',
max_y: 120,
xax_start_at_min: true,
transition_on_update: true,
y_extended_ticks: true,
interpolate: 'linear',
x_accessor: 'date',
y_accessor: 'value',
target: '.result'
};
setInterval(function () {
var date = new Date();
//set min and max when some data is present
if (data.length > 6) {
options.min_x = new Date(+data[data.length - 3].date);
options.max_x = new Date(+options.min_x + 6000);
}
// add new value
data.push({
date: date,
value: Math.random() * (100 - 0) + 0
});
options.data = data;
MG.data_graphic(options);
}, 1000); |
Yes, this improved the behavior but there is still a exception.
From a quick look the fix you've applied would help at line 1673, too. |
I can definitely confirm that using the same options object multiple times is no longer an issue. |
If you wouldn't mind verifying that the latest commit fixes your last exception. |
I use bower and reference the master branch to pull in the latest changes - in your latest commit the bower dist js-files are completely emptied - was this by accident? |
Aah, my bad. Committed, before it finished building. |
All working fine now :) |
Great :) |
Tried out the new option and it breaks for me with this message.
Used data structure is:
You can checkout this branch where it is demonstrated.
The text was updated successfully, but these errors were encountered: