Home forums Using CanvasJS display legent without data

This topic contains 6 replies, has 2 voices, and was last updated by  Vishwas R 6 months, 2 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #20494

    larry
    Member

    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

    #20496

    Vishwas R
    Keymaster

    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

    #20499

    larry
    Member

    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?

    #20500

    Vishwas R
    Keymaster

    Larry,

    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.


    Vishwas R
    Team CanvasJS

    #20501

    larry
    Member

    Vishwas,

    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’

    Thanks,
    Larry

    #20550

    larry
    Member

    Hi,

    do you have solution for this problem?
    please tell me if my example not clear enough

    Thanks,
    Larry

    #20577

    Vishwas R
    Keymaster

    Larry,

    You can set the dataPoint value to first dataPoint x-value of any other dataSeries. Please take a look at this updated jsfiddle.


    Vishwas R
    Team CanvasJS

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.