Pie chart does not show more than 8 colors dynamically

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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 sharan on 25th September 2012
hi to all.This is sharan,am using r.graphs,by using this am drawing a pie chart with dynamic values..when those values more than 8 then the colors are repeating again...i want different values with different colors dynamically..please help me..
Posted by on 25th September 2012
Hi,

You're simply running out of default colors - ie there's only 8
default colors with the Pie chart. You can change that with this:

<script>
     colors = ['red', '#ddd', '#0f0', 'blue', 'pink', 'yellow',
'black', 'cyan', 'red', '#ddd', '#0f0', 'blue', 'pink', 'yellow',
'black', 'cyan'];

     myPie.Set('chart.colors', colors);
</script>

That will give you 16 colors.
Posted by on 29th September 2012
make another jsp or file with say 1000 colors . and call this file in place of the colors in your script. This solves the problem for 1000 segments of the pie, but if there are more than 1000 colors , you need to add the same in your colors file.

file Eg :
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'red', 'red'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'gray', 'gray'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, '#0f0', '#0f0'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'blue', 'blue'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'pink', 'pink'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'purple', 'purple'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'red', 'red'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'gray', 'gray'),
RGraph.RadialGradient(pie1, 200,150,0,200,150,150, '#0f0', '#0f0'),

and so on.........

Posted by on 1st October 2012
Hi,

It would be less code if you put that in a loop too:

var colors = ['red','gray','#0f0','blue','pink','purple','red','gray','#0f0'];

for (var i=0; i<colors.length; ++i) {
     RGraph.RadialGradient(pie1, 200,150,0,200,150,150, 'white', colors[i]);
}

Add a reply




« Back to message list