简体   繁体   English

flot条形图中的不同颜色条可以吗?

[英]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 ? 是否有支持的机制,使用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. Flot仅允许在数据级别指定点的颜色,这意味着每种颜色必须是其自己的数据。 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. 有一个Flot插件,允许您根据您设置的阈值设置颜色。 You can get the plugin code here: https://github.com/subhrajitroy/Flot-plugin/blob/master/jquery.flot.threshold.multiple.js 您可以在此处获取插件代码: https//github.com/subhrajitroy/Flot-plugin/blob/master/jquery.flot.threshold.multiple.js

Flot is now shipped with a plugin that does just that. Flot现在附带了一个插件,可以做到这一点。

Internally it splits a series into several series and assign a different color to each. 在内部,它将一系列分成几个系列,并为每个系列分配不同的颜色。

The plugin is in flot's github page here: 该插件位于flot的github页面中:
https://github.com/flot/flot/blob/master/jquery.flot.threshold.js https://github.com/flot/flot/blob/master/jquery.flot.threshold.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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