如何为flot中的条形图提供纯色 [英] How to give solid colors to bar charts in flot
问题描述
I need to give solid colors to bar charts... I have followed this link Bar chart Example
但我想给出纯色,我还需要自己更改颜色...怎么做...
But i want to give solid colors and also i need to change colors myself... how to do it...
推荐答案
首先,阅读 API.txt ,它会回答您的所有问题。那么你需要做两件事。当您指定要条形图时,设置 fill:1
,告诉flot使颜色100%不透明。要为每个系列指定颜色,只需为每个数据对象添加颜色:'red'
。
First off, read the API.txt, it answers all your questions. Two things you need to do then. When you specify that you want bars, set fill: 1
, which tells flot to make the colors 100% opaque. To specify a colour per series, just add a color:'red'
to each data object.
所以你最终得到这样的数据对象:
So you end up with a data object like this:
var data = [
{label: 'foo', color:'red', data: [[1,300], [2,300], [3,300], [4,300], [5,300]]},
{label: 'bar', color:'blue', data: [[1,800], [2,600], [3,400], [4,200], [5,0]]},
{label: 'baz', color:'yellow', data: [[1,100], [2,200], [3,300], [4,400], [5,500]]},
];
和这样的flot选项:
And flot options like this:
{
series: {
stack: 1,
bars: {
show: true,
barWidth: 0.6,
fill:1
}
}
}
参见它在这里行动: http://jsfiddle.net/ryleyb/kKdxt/
这篇关于如何为flot中的条形图提供纯色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!