Xhynk
Xhynk

Reputation: 13890

Change 'color scheme' in Raphael.js?

I don't want to use the default color's in a donut chart in raphael.js. The default is something like Red - Orange - Yellow.... etc.

Ideally, I'd like to set up custom colors, like so:

colors: [
    '#f00',
    '#0f0',
    '#00f'
];

I've got a FIDDLE, with the fill variables set as color and bcolor

Upvotes: 1

Views: 171

Answers (1)

Paul Lo
Paul Lo

Reputation: 6148

I think you are pretty close, please see my revision here: http://jsfiddle.net/9GN6z/

1.Add your custom color before angle=0:

var colors= ['#f00', '#0f0','#00f']

2.Replace

bcolor = Raphael.hsb(start, 1, 1) 

with

bcolor = colors[j%colors.length]

to apply your custom color. Hope it would help :)

Upvotes: 2

Related Questions