Question

I'm using jqPlot and I'm wondering if instead of showing all bars in 'blue', I could show them in 'red' or whatever I want :

    jQuery(document).ready(function(){
      var data = <?php echo $times; ?>;
      var plot1 = jQuery.jqplot('chart-time', [data], {
          title:'Pages per Hours',
          stackSeries: true, 
          seriesDefaults: {
              renderer: jQuery.jqplot.BarRenderer,
              rendererOptions:{barMargin: 10, shadow:false}, 
              pointLabels:{show:true, stackedValue: true}
          },
          axes: {
              xaxis:{renderer:jQuery.jqplot.CategoryAxisRenderer,
                label:'(Hours)'}
          }
      });

    });

Thanks

Was it helpful?

Solution

You can do this by adding a color property to your seriesDefaults:

jQuery(document).ready(function(){
  var data = <?php echo $times; ?>;
  var plot1 = jQuery.jqplot('chart-time', [data], {
      title:'Pages per Hours',
      stackSeries: true, 
      seriesDefaults: {
          renderer: jQuery.jqplot.BarRenderer,
          rendererOptions:{barMargin: 10, shadow:false}, 
          pointLabels:{show:true, stackedValue: true},
          color: '#FF6666'
      },
      axes: {
          xaxis:{renderer:jQuery.jqplot.CategoryAxisRenderer,
            label:'(Hours)'}
      }
  });

});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top