Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set series color

Tags:

jquery

flot

How to set colors of all series in flot as same?

like image 969
Nisanth Kumar Avatar asked Nov 30 '25 06:11

Nisanth Kumar


2 Answers

When you're providing the data, give them the same color property or index.

For example:

[ { color: 0, label: "Foo", data: [ [10, 1], [17, -14], [30, 5] ] },
  { color: 0, label: "Bar", data: [ [11, 13], [19, 11], [30, -7] ] } ]

In this case they'd both get color #0 in the auto-generated color array Flot has.

like image 51
Nick Craver Avatar answered Dec 02 '25 19:12

Nick Craver


You can pass an array of colors in the options as well:

$.plot($("#plot"), [plotData], { colors: ['#0000FF'] });
like image 22
jgillich Avatar answered Dec 02 '25 19:12

jgillich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!