简体   繁体   中英

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

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM