2

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", ...)?

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.