Jqplot 中两个系列数据的不同颜色条
我想知道如何在 Jqplot 中为两个系列制作不同的颜色条。如果我只有一个系列数据,它的工作原理就像下图一样
基于其值的红色和绿色。
但是,如果我有两个系列数据,我无法为每个系列数据配置两个系列颜色。到目前为止,我只能制作此图
我希望两个系列图可以根据其值具有不同的颜色以及一系列图表。
这是
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 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.
This is my code
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}
});
I have tried seriesColors : [seriesColors1, seriesColors2]
but it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
基本上,您需要创建一个系列数组,其中每个条目包含一个字典,以及一个
seriesColors
条目。下面显示了一个工作示例jsfiddle:(如果我外部js文件,小提琴可能会停止工作已更改;jsfiddle 默认没有 jqplot 库。)
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:(The fiddle may stop working if I the external js files are changed; jsfiddle doesn't have jqplot libraries by default.)
我今天遇到了这个问题,正如 jimbob 博士所预测的那样,所有外部文件都已屈服于链接腐烂。我找到了一个 CDN 站点并将小提琴更新到最新的 jQuery & JQPlot 资源文件,可在此处获取:http://jsfiddle.net/delliottg/WLbGt/96/
只是为了满足 JSFiddle 警察的要求,他们不允许我在没有它的情况下发布此内容:
我与小提琴本身无关,我只是更新了它,所以它可以工作。希望这对某人有帮助(事实证明这不是我想要的,但是你付钱并且你要抓住机会)。
I came across this today and as dr jimbob had predicted, all the external files had succumbed to link rot. I found a CDN site and updated the fiddle to the latest jQuery & JQPlot resource files, available here: http://jsfiddle.net/delliottg/WLbGt/96/
Just to satisfy the JSFiddle cop on SO that won't let me post this w/o it:
I had nothing to do with the fiddle itself, I just updated it so it worked. Hope this helps someone (turns out it wasn't what I was looking for, but ya pays yer money & ya takes your chances).