MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to use for showing charts on your website.

More »

 

Download
Get the latest version of RGraph (version 6.18, 1st June 2024) from the download page. You can read the changelog here. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£129) commercial license available.

More »

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


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

Posted by Richard at 15:29 on Tuesday 30th March 2021 [link]
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]];

[Replies are closed]