mercredi 28 janvier 2015

RGraph: how to change background color?


I have a web page with 3 rgraph dynamically updated Line charts. I use ajax call for retrieving data from web service. When ajax call completed with error I want to change the chart background color to 'gray'. And when call is successful to change this color to 'black'.


How to change chart background color dynamically?


I use this code



if(error_occured)
obj_Memory.Set('background.color', '#B6B6B4');
else
obj_Memory.Set('background.color', 'black');


But it does not change the color.


I modified rgraph sample:


http://ift.tt/1CN7ESs


Added button and simple function:



var error_occured = false;

document.getElementById("toggleButton1").onclick = function (e) {
if (error_occured)
obj.Set('background.color', '#B6B6B4');
else
obj.Set('background.color', 'black');
RG.redraw();
error_occured = !error_occured;
}


It does not change the chart background





Aucun commentaire:

Enregistrer un commentaire