如何设置jqplot条形图的颜色每栏? [英] How to i set jqplot bar chart colours per bar?

查看:367
本文介绍了如何设置jqplot条形图的颜色每栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设置我的jqplot条形图栏的颜色。将总有六个酒吧,分组成2个酒吧的集合。下面是正在绘制的数据示例:

  line1 = [6000,5000,5500] 
line2 = [16000,10000,14000];

到目前为止我已经使用了以下方法:

  seriesColors:[#F3CBBF,#BFDDE5,#CF3501,#027997,#CF3501,#027997],

但是jqplot每次在前两个小节之间交替,而不是使用所有声明的颜色。这可能是因为它只确定存在两个系列,每组数据一个。



是否有明确设置条颜色的方法?

解决方案

我使用 varyBarColor方法,因此您可以像简单数组一样列出不同的颜色,如果只有一个系列,它将使用这些颜色为每个酒吧。下面是我的代码示例:

  plot1 = $ .jqplot('chart1',[s1],{
title:'Example Income Graph',
seriesDefaults:{
renderer:$。jqplot.BarRenderer,
rendererOptions:{varyBarColor:true},
pointLabels:{show:true }
},
axes:{
xaxis:{
renderer:$ .jqplot.CategoryAxisRenderer,
label:'净增长(%)',
ticks:ticks
},
yaxis:{
label:'Income(& pound;)',
tickOptions:{formatString:'%d'},
autoscale:true,
min:0,
max:10000
}
},
系列颜色:[#eee,#ccc #999],
highlighter:{show:false}
});

在这张图中,我有一个有3个条形的系列,每个都是不同的颜色灰色。 p>

I'm trying to set the colours of my jqplot bar chart bars. There will always be six bars present, grouped into sets of 2 bars. Here is an example of the data being plotted:

 line1 = [6000, 5000, 5500];
 line2 = [16000, 10000, 14000];

I've used the following so far:

 seriesColors: ["#F3CBBF", "#BFDDE5", "#CF3501", "#027997", "#CF3501", "#027997"],

But jqplot alternates between the first 2 bars each time instead of using all of the declared colours. This is probably as it only determines 2 series being present, one per set of data.

Is there a way to set the bar colours explicitly?

解决方案

I do this using the varyBarColor method so you can list the different colours for the bars in a simple array like you have done already but if there is only one series it will use these colors for each bar instead. Here is an example of my code:

plot1 = $.jqplot('chart1', [s1], {
        title: 'Example Income Graph',
        seriesDefaults:{
            renderer:$.jqplot.BarRenderer,
            rendererOptions:{ varyBarColor : true },
            pointLabels: { show : true }
        },
        axes: {
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,
                label:'Net Growth (%)',
                ticks: ticks
            },
            yaxis:{
              label:'Income (£)',
              tickOptions:{ formatString:'%d'},
              autoscale:true,
              min:0, 
              max:10000
            }
        },
        seriesColors: [ "#eee", "#ccc", "#999"],
        highlighter: { show: false }
    });

In this graph I had one series with 3 bars and they are each a different colour grey.

这篇关于如何设置jqplot条形图的颜色每栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆