简体   繁体   中英

Different colour bars in a flot bar graph, is this possible?

I have looked through the documentation and the only reference I can find is for different colour series . However I have only one data series and would like points/bars on that series different colours.

I could use multiple series and make points set to zero, which would have the same effect.

Is there a supported mechanism for having different colour bars in a bar graph using flot ?

There isn't built in support for using multiple colors in a single series.

Flot only allows specifying colors of the dots at the dataseries level, meaning each color must be its own dataseries. With this in mind, the solution is to make a single dataseries for each color.

There is a Flot plugin that allows you to set the color based on threshold values that you set. You can get the plugin code here: https://github.com/subhrajitroy/Flot-plugin/blob/master/jquery.flot.threshold.multiple.js

Flot is now shipped with a plugin that does just that.

Internally it splits a series into several series and assign a different color to each.

The plugin is in flot's github page here:
https://github.com/flot/flot/blob/master/jquery.flot.threshold.js

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