How to give solid colors to bar charts in flot

廉价感情. 提交于 2019-12-22 04:29:19

问题


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...


回答1:


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]]},
];

And flot options like this:

{
    series: {
        stack: 1,
        bars: {
            show: true,
            barWidth: 0.6,
            fill:1
        }
    }
}

See it in action here: http://jsfiddle.net/ryleyb/kKdxt/



来源:https://stackoverflow.com/questions/9311147/how-to-give-solid-colors-to-bar-charts-in-flot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!