Jqplot中两个系列数据的不同颜色条 [英] Vary Color Bar For Two Series Data in Jqplot

查看:69
本文介绍了Jqplot中两个系列数据的不同颜色条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Jqplot中为两个系列制作不同的颜色条.如果我只有一个系列数据,那么它的工作原理就像下面的图片一样

I want to know how to make vary color bar for two series in Jqplot. If I have only one series data, it works perfectly like the image below

基于其值的红色和绿色.

The red and green color based on its value.

但是,如果我有两个系列数据,则不能为每个系列数据配置两个系列颜色.到目前为止,我只能制作这张图

But if I have two series data, I can't configure to have two series color for each series data. So far, I can only make this graph

我希望两个系列图可以根据其值以及一个系列图具有不同的颜色.

I want the two series graph can have vary color based on its value as well as the one series graph.

这是我的代码

chart = $.jqplot('map-chart', [dataChart, dataChart2], {
        title: 'TIME',
        legend: {
            renderer: $.jqplot.EnhancedLegendRenderer,
                        show: true,
                        location: 'ne'
        },
        series: [{label: 'Current data'}, {label: 'Worst data'}],
        //seriesColors: seriesColors1,
        seriesDefaults:{
            renderer:$.jqplot.BarRenderer,
            pointLabels: {show: true}
            //rendererOptions:{
             //varyBarColor: true
            //}
        },
        axes: {
            xaxis: {
                label: 'station',
                renderer: $.jqplot.CategoryAxisRenderer,
                labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
                tickRenderer: $.jqplot.CanvasAxisTickRenderer,
                ticks: tickers,
                tickOptions: {
                    angle: -30
                }
            },
            yaxis: {
              min: 0,
              label: 'Time',
              labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
              tickOptions: {
                    fontSize: '8pt'
              }
            }
        },
        highlighter: {show: false}
    });

我尝试了seriesColors : [seriesColors1, seriesColors2],但是没有用.

I have tried seriesColors : [seriesColors1, seriesColors2] but it didn't work.

推荐答案

基本上,您需要创建一个序列数组,该数组每个条目都包含一个字典,并带有一个seriesColors条目.下面的 jsfiddle

Basically you need to create a series array, that contains a dictionary per entry, with a seriesColors entry. A working example is shown in the following jsfiddle:

plot1 = $.jqplot('chart1', [[50,100,50,50,75],[80,70,50,50,40]], 
{
        seriesDefaults:{
            renderer:$.jqplot.BarRenderer,
            rendererOptions:{ varyBarColor : true }
        },
        series: [
            {seriesColors: [ "#f00", "#4b0", "#b40", '#ff0', '#fb0']}, 
            {seriesColors: ["#a30", "#4b0", "#b40", '#af0', '#fa0']}
            ],
        highlighter: { show: false }
});

(如果更改了外部js文件,小提琴可能会停止工作;默认情况下jsfiddle没有jqplot库.)

(The fiddle may stop working if I the external js files are changed; jsfiddle doesn't have jqplot libraries by default.)

这篇关于Jqplot中两个系列数据的不同颜色条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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