[RGRAPH SUPPORT] How can I set the data on a Bar chart dynamically?

How can I set the data on a Bar chart dynamically?

Post a reply
Posted by Mohamed on 13:14 30th March 2021
How can be the data set in a bar dynamically?
myBar.original_data[0] = newData; //is not working

Posted by Richard on 15:29 30th March 2021
The original_data variable is a Line chart variable - for the Bar chart you need to set the data slightly differently; and then, crucially, call the RGraph.redraw() function. For example:

function setData (obj, data)
{
    obj.data = data;
    RGraph.redraw();
}

Which you would call like this:

setData(myBar, newData);

And the format of the newData array should be like this:

// Regular Bar chart
newData = [4,8,6,3,5,4,8];

// Grouped or stacked data
newData = [[3,5,6],[2,5,8],[7,6,3],[8,5,7],[4,9,9],[5,2,3],[4,8,6]];

Post a reply

What's your name?
What do you want to say?