I'm getting a weird Bipolar color behaviour

« 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 john sandberg on 21st February 2013
first off, here's my code:

     window.onload = function () {
     var bipolar = new RGraph.Bipolar('preview', [18, 31, 9, 4, 5, 32, 24, 2, 0], [18, 44, 14, 2, 2, 49, 14, 6, 0]);
     var grad = bipolar.context.createLinearGradient(0,0,600,0);

     bipolar.Set('chart.labels', ['1', '2', '3', '4', '5', '6', '7', '8', '9']);
     bipolar.Set('chart.colors', [grad]);
     bipolar.Set('chart.labels.above', true);
     bipolar.Set('chart.title.left', '1');
     bipolar.Set('chart.title.right', '2');
     bipolar.Set('chart.gutter.center', 110);

Multiple problems here:
1) If I use a color array of 18 (repeating 9 separate color codes), it breaks when the source input is 0. I also tested this by setting the 0 to -1 and at that point, the color for the 0/-1 is repeated one time also breaking the color flow.

2) This current example draws the left side bars with the gradient but fails to draw any bars on the right hand side (teseted in chrome and ie)

I've tried everything I can think of with chart.colors.sequential set to true and false and can't get the desired functionality I need.

I feel like I have to be missing something here. I can't imagine that if the input is 0 (actually set to zero, not a null), then the bar colors just skip a turn or fail to draw at all).

Posted by RGraph support on 22nd February 2013
Hi there,

I have a feeling that you're creating your gradients not quite correctly and need an extra color stop:

var grad = bipolar.context.createLinearGradient(0,0,600,0);

Like the red Bipolar here:



Add a reply

« Back to message list