我有条形图和以下代码:
var line1=[['0-1',275134],['2-3',261562],['4-5',285681],['6-7',915432],['8-9',555131]];
var line2=[['0-1',353628],['2-3',287898],['4-5',297550],['6-7',103313],['8-9',616089]];
jQuery.jqplot('_container', [line1, line2],
{
title: 'title',
seriesColors: [ "#eee", "#ccc"],
seriesDefaults:{
renderer:jQuery.jqplot.BarRenderer,
rendererOptions:{barPadding:5, barMargin:5,highlightColors: ["#000", "#FF1100"]},
pointLabels: {show: false}
},
legend:{
renderer: jQuery.jqplot.EnhancedLegendRenderer,
show:true,
showLabels: true,
labels: ["Label 1", "Label 2"],
rendererOptions:{numberColumns:2},
placement:'outsideGrid',location:"s"
},
axes:{
xaxis:{renderer:jQuery.jqplot.CategoryAxisRenderer, rendererOptions:{showDataLabels: false},showTicks: false},
yaxis:{tickOptions: {showGridline: true}}
},
highlighter: {
tooltipAxes: 'y',
formatString:'%s'
},
cursor:{style:'default', show: true, zoom:true, showTooltip:false}
});
如何通过seriColors的工作方式为条形添加高亮显示,因此添加的highlightColors以另一种方式工作,它突出显示前四个条形图(“#000”,“#000”,“#FF1100”,“#FF1100”),但是需要的结果是(“#000”,“#FF1100”,“#000”,“#FF1100”,“#000”,“#FF1100”,...)?
答案 0 :(得分:1)
您在此遇到的问题是由barRenderer.js
中的错误造成的,修复它的唯一方法似乎是编辑其代码的相应行, as explained here.
所需的更改包括在行中替换pidx
sidx
:
var opts = {fillStyle: s.highlightColors[pidx]};
为了验证它,我提出了a jsfiddle where you can quickly see that it fixes问题。