You must be logged in to post your query.
Home › Forums › Chart Support › Show Difference Between First Datapoint and Last Datapoint
Is there a way to dynamically show the difference between the first datapoint and the last datapoint on a line chart? Thanks.
For example, if we wanted to show weight loss, and there were three datapoints: 300; 280; and 265. Weight loss would be 20 on the second point and 35 on the third point. Is there a way to show that without hard coding it? Thanks.
@1CoolDude,
You can achieve your requirements by showing the difference between dataPoints as indexLabel as shown in this JSFiddle.
— Adithya A Menon Team CanvasJS
Works great. Thanks.
I noticed that this works unless there are decimal places introduced. For example, 299.8 and 291.7. Then it returns 15 decimals places. Is there a way to have it return only on decimal place? Thanks.
You can format a number to fix decimals using formatNumber method. Please take a look at this JSFiddle for an example.
Very helpful. Thanks so much.
You must be logged in to reply to this topic. Login/Register