BarRenderer更改默认颜色

时间:2014-03-06 12:36:07

标签: jquery jqplot

我正在使用jqPlot,我想知道如果不是以'蓝色'显示所有条形图,我可以用'红色'或任何我想要的方式显示它们:

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

    });

由于

1 个答案:

答案 0 :(得分:1)

您可以通过向color添加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)'}
      }
  });

});