Home Forums Chart Support Chart always rendering, unable to change data.

Chart always rendering, unable to change data.

Viewing 2 posts - 1 through 2 (of 2 total)
  • #19218

    wtf

    Despite the fact that I am not calling the render function, the charts always appear and cannot be changed by changing the data and re-rendering.

    Codepen example:

    https://codepen.io/extrachrisb/pen/eVNrxd?editors=1111

    #19234

    @wtf,

    Despite the fact that I am not calling the render function

    The chart is getting rendered as change method is called which in turn calls chart.render().

    function change() {   
        newTitle = "is going on";
        chart.render(); // chart.render() gets called inside change
    }
    change(); // Call to the change method

    Please take a look at this MDN Page on Javascript Functions.

    cannot be changed by changing the data and re-rendering.

    The title is not being updated as chart options are not updated within change method instead, you are updating newTitle. You can use set method to update the chart title. Please add the following line after chart.render() method in change();
    chart.title.set("text", newTitle);

    You can take a look at this Documentation Link on set() for more info.

    Also, we noticed that you haven’t set the dataPoints properly. dataPoints should be an array which is number in your case.
    dataPoints: 0 // incorrect, should be an []

    The chart should work fine after making all these changes.
    ___
    Suyash Singh
    Team CanvasJS

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

You must be logged in to reply to this topic.