Home Forums Chart Support How to update indexLabel with label and value.

How to update indexLabel with label and value.

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

    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

    @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

    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 7 years, 2 months ago by jeppy7.
    #17380

    @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.