Hi,
Thanks for contacting us with your question!
In your add point function, you assign to your new point the same time stamp - x value - as the last one, hence overlap occurs.
Assuming that the interval is one minute, you can modify your function in the following way:
Code: Select all
function addPoint() {
const series = chart_obj.series[0];
let last = series.points[series.points.length - 1];
let new_x = last['x'] + 60 * 1000;
let update_data = {
x: new_x,
open: last['open'] + Math.floor(Math.random() * 2 - 1),
high: last['high'] + Math.floor(Math.random() * 2 - 1),
low: last['low'] + Math.floor(Math.random() * 2 - 1),
close: last['close'] + Math.floor(Math.random() * 2 - 1)
};
const shift = series.data.length > (6 * 60 * 24);
series.addPoint(update_data, true, shift);
chart_obj.redraw();
}
Please see your code with the change implemented:
https://jsfiddle.net/BlackLabel/m8o7hLw0/
I hope you will find it useful.
Best regards,