How can I set gradient effects on pie charts?
[{
label: i,
data: 1000,
color: [ "rgb(190,110,110)", "rgb(140, 70, 70)", "rgb(110, 50, 50)", "rgb(60, 10, 10)" ]
},
//nextserie
]
doesn't work.
Also how can I set gradient effects as default colors for my charts? In the way you can index it by number like:
[{
label: i,
data: 1000,
color: 1,
},
//nextserie
]
The library doesn't support that, currently. If you're comfortable merging patches, there was one submitted along with issue 355 (follow the link to the original Google Code issue to get the attachment) that adds gradients to pies. I haven't tried it myself yet, though.
I have now added support for rendering pie chart with gradients, either radial or linear. My commit is referenced in pull request #853.
An example "default" pie chart with a radial gradient:
An example donut chart with a radial gradient:
An example of a tilted pie chart with a radial gradient:
The changes were based on a combination of the above suggestions proposed by @Hoffman and a patch suggested in Flot issue #355 by Luc Boudreau.
Ok, so I did it myself. Took me a while to understand how flot works internally, but eventually I found the part where I needed to change. On jquery.flot.pie.js change the drawSlice function (line 406 on Flot 0.7) to:
don't remove the rest of the code after the if.
And like magic now you can define your series with radial gradient colors:
I will try to make a cool graph then I will screenshot it and post here.
EDIT: Here you go:
It's a lot better than using solid colors, but it can get a lot better, I'm just bad at picking colors. Now I found a small problem, legends don't work with my changes, no color will be displayed on them. I'm not willing to fix that since that functionality is present on the core Flot file (which is a lot bigger and complex than the pie plugin) and I don't have much free time to mess with that.