Problem creating key for bar chart

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Jonathan Martinez on 11th December 2012
Hi,

I am trying to create a key for a graph that has two colors. I want the key to show that blue is before and red is after.

I have tried this "bar5.Set('chart.key',['BEFORE','AFTER']);" and other variations but it doesn't work.

Here is the code I am using right now:

var bar5 = new RGraph.Bar('cvs', [[23853,185000]]);
             bar5.Set('colors', ['#11CCCC', '#CC1111']);
             bar5.Set('tooltips', ['BEFORE','AFTER']);
             bar5.Set('labels', ['TEST LABEL']);
             bar5.Set('strokestyle', 'transparent');
    bar5.Set('chart.text.angle', 45);
             bar5.Set('chart.gutter.left',100);
    bar5.Set('chart.gutter.bottom',200);
    bar5.Set('chart.xlabels.offset',10);
    bar5.Set('chart.title','TEST HEADER');
    bar5.Set('chart.shadow','TRUE');
    bar5.Draw();

Thanks for the help.
Posted by RGraph support on 11th December 2012
Hi,

Exactly what is happening? The key normally uses the same colors as what you set with chart.colors but you be specific if you prefer by using chart.key.colors.
Posted by Jonathan Martinez on 11th December 2012
For example, if I add:

bar5.Set('chart.key',['BEFORE','AFTER']);

Nothing happens and the tooltips stop working;

I used the examples in this page:

www.rgraph.net/docs/keys.html
Posted by RGraph support on 11th December 2012
Hi,

1. Have you included the key library?
2. What does your console say?
Posted by Jonathan Martinez on 11th December 2012
That was it, I was forgetting to add the RGraph.common.key.js library.
Thanks.
Posted by RGraph support on 11th December 2012
Hi,

Add a reply




« Back to message list