Home forums Using CanvasJS How to update indexLabel with label and value.

This topic contains 3 replies, has 2 voices, and was last updated by  Indranil Deo 4 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17353

    jeppy7
    Member

    This is for a pie chart. How do I update the indexLabel when the indexLabel contains both the label and the value? IE – chart.options.data[0].dataPoints[0].indexLabel = ???; In the indexLabel setup I have indexLabel: “{label} {y}”. So if I have a label and a value in the indexLabel, how can I update the value part?

    #17358

    Indranil Deo
    Member

    @jeppy7,

    You are setting the indexLabel at dataPoint level. Instead, setting it at dataSeries level will work fine in your case.
    chart.options.data[0].indexLabel = "{label} {y}";

    __________
    Indranil Deo,
    Team CanvasJS

    #17370

    jeppy7
    Member

    That’s almost correct. I was actually able to get it sort of working. I can use either chart.options.data[0].dataPoints[0].indexLabel = “{label} {y}”; or chart.options.data[0].indexLabel = “{label} {y}”; but the only way I can get it to show up is if I call chart.render() again after the change. When I do that I get some weird behavior though. The circle doesn’t redraw very well, etc. Is there any way to get the updated options to show on screen without having to call chart.render()?

    • This reply was modified 4 weeks, 1 day ago by  jeppy7.
    #17380

    Indranil Deo
    Member

    @jeppy7,

    You should call chart.render() to render chart once options are set or updated. You can also use set method to achieve the same without calling chart.render() as the method re-renders chart.
    chart.data[0].set("indexLabel", "{label} {y}");.
    Note: Chart should be rendered once before you can use set method

    When I do that I get some weird behavior though. The circle doesn’t redraw very well, etc.

    Can you kindly create jsfiddle reproducing the issue, so that we can understand it better and help you out?

    ___________
    Indranil Deo,
    Team CanvasJS

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

You must be logged in to reply to this topic.