You must be logged in to post your query.
Home › Forums › Chart Support › display legent without data
Tagged: legend data dataPoints
Hello,
how can I display all legend text even if dataPoints: [] is empty?
(I want user to see the serieses that going to be display even if data not arrived yet).
Thanks, Larry
Larry,
You can add an empty object to dataPoints to show legend and remove the empty object when you update dataPoints. Please take a look at this jsfiddle.
— Vishwas R Team CanvasJS
Vishwas,
thanks for your reply, I have 2 questions about it: 1. is it different from just add empty objects as default to each dataPoint? also no need to delete it 2. as you can see in your solution, Xaxis is changed due to this solution. why its happens?
1. is it different from just add empty objects as default to each dataPoint? also no need to delete it
Both are same. However empty object in a dataSeries can affect axis-range.
2. as you can see in your solution, Xaxis is changed due to this solution. why its happens?
That’s because of empty object. To avoid this you can add a dataPoint with y-value set to null. Please take a look at this updated jsfiddle.
this is better solution for me, but I still have problem:
Xaxis is Date , I dont know what will be the Date I receive (its realTimeChart, Date can be random), so lets say I set the dummy data to ‘April 30, 2018’ for ‘series1’ but ‘series2’ getting data with xValue: ‘April 30, 2022’.
it will cause an empty gap betwen ‘April 30, 2018’ – ‘April 30, 2022’
Hi,
do you have solution for this problem? please tell me if my example not clear enough
You can set the dataPoint value to first dataPoint x-value of any other dataSeries. Please take a look at this updated jsfiddle.
You must be logged in to reply to this topic. Login/Register