The background properties are not being updated after the initial draw


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Ryan on 27th October 2017
I have an issue with changing properties that are related to the graph backgrounds. For instance if i add a bar graph to a webpage, and set that background color to blue initially, the graph renders with a blue background. If i then use the code:

barID.set('backgroundColor','red');
or,
barID.set({backgroundColor:'red'});

followed by:
RGraph.clear(bar48f80.canvas);
barID.draw();

The graph's background is still blue, not red. The same thing happens with the gutter properties, but with gutters, the actual graph does get the new gutters, but the background behind it retains the original gutters, creating an ugly offset between the graph's axis and the edge of the background. Is this a bug or am i missing something?

Thanks,
Ryan
Posted by Richard on 27th October 2017
Hi there,

What's happening is the background grid is being cached (to increase performance in animations). To work around this you need to reset the cache just before you redraw the chart. ie You need to do:

RGraph.cache = [];
RGraph.clear(bar48f80.canvas);
barID.draw();

Richard
Posted by Ryan on 27th October 2017
Thank you this is exactly what i was looking for.

Add a reply




« Back to message list