Home › forums › Using CanvasJS › Problem in displaying Legend
I have a working jsfiddle code below where the chart is rendering as expected but the problem is same legend(chart key) is showing different colors as repeating text which is not expected. My requirement is if the chart has same key(legend) that should fall under same color without repeating. Please help me to resolve this issue.
Legends are shown for each dataSeries with a marker and the text. In your case, it shows same name in multiple colors as you are passing same name to multiple dataSeries. Parsing JSON properly and passing legendText / name according to the dataSeries that you are creating dynamically should work fine. Please take a look at this JSFiddle for an example on multi-series chart from JSON file.
Thank you Manoj for your reply. But in my case, the data is coming as same name(legends in my case) for different months. I can’t change the data since it is coming from DB. Please have a look in these data and help me to resolve it.
Categorising dataseries based on the legendText (Short/Answer column in database) instead of doing it based on month number should work fine in this case. Please take a look at this JSFiddle which shows categorizing dataseries based on label from JSON.
Thanks for your response. But it’s client’s requirement to display legendText as ShortAnswer column NOT the month number. Can you please suggest how can I get this issue resolved?
The sample provided by @manoj-mohan seems to work fine with your case. Please take a look at this updated JSFiddle.
You must be logged in to reply to this topic.