salvezza
salvezza

Reputation: 115

jqplot highlights per bar

I have bar chart and the following code for that:

 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}
 });

How to add highlighting for bars by way as seriesColors works, so added highlightColors works by another way it's highlight first four bars ("#000", "#000","#FF1100","#FF1100"), but needed result is like ("#000","#FF1100","#000","#FF1100","#000","#FF1100", ...)?

Upvotes: 2

Views: 1298

Answers (1)

Boro
Boro

Reputation: 7943

The issue you experienced here was caused by a bug in the barRenderer.js and the only way to fix it seems to be edit of the appropriate line of its code, as explained here.

The required change involves replacing of pidx with sidx in the line:

var opts = {fillStyle: s.highlightColors[pidx]};

To verify it, I made a jsfiddle where you can quickly see that it fixes the problem.

Upvotes: 1

Related Questions