Home › Forums › Chart Support › Need some help regarding my usage scenario › Reply To: Need some help regarding my usage scenario
I have solved 2 and 3. .toFixed converts the number to sting. so, the chart rendering fails. Also, the correct way to display a live data is to use shift method on the datapoint array. This is mentioned in the Docs
.toFixed
But I am still struggling with the 1st issue. The first point has the correct time axis. Then, for 10 seconds some ms is getting displayed and then again correct date-time is being displayed.
ms
I am using the following hack to overcome this behavior. If the datapoint array length is 0, I am adding 2 more data points. 1. (x: 10 sec ago and y: 0) This does not look good because of the line continuity. Thus I am also adding 2. (x: 10 ms ago and y: 0)
if(dataPoints1.length==0){ dataPoints1.push({ x: new Date(Date.now() - 10000), y: 0 }); dataPoints2.push({ x: new Date(Date.now() - 10000), y: 0 }); dataPoints1.push({ x: new Date(Date.now() - 100), y: 0 }); dataPoints2.push({ x: new Date(Date.now() - 100), y: 0 }); }