2016-10-03 53 views
-1

如何更改高图表中两个类别的颜色?下面是我的代码:更改高亮​​栏的柱状图颜色

exec_dashboard_load_graph(
    'exec_dashboard_collection_disbursement_graph', 
    response, 
    ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']      
); 

function exec_dashboard_load_graph(id,data, x){ 
    var myChart = Highcharts.chart(id, { 
     chart: {type: 'column'}, 
     title: {text: 'Annual Collection and Disbursement Summary'}, 
     subtitle:{text: 'City Goverment of Butuan'}, 
     xAxis: {categories: x,crosshair: true}, 
     yAxis: {min: 0,title: {text: 'Amount (Peso Value)'}}, 
     tooltip:{ 
      headerFormat: '<span style="font-size:10px">{point.key}</span><table>', 
      pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + 
     '<td style="padding:0"><b> {point.y:.1f} Php </b></td></tr>', 
      footerFormat: '</table>', 
      shared: true, 
      useHTML: true 
     }, 
     plotOptions: {column: {pointPadding: 0.2,borderWidth: 0}}, 
     series: data  
    }); 
} 

数据变量包含以下值:

enter image description here

+0

您可以添加你的颜色你的具体数据点内,在这里你可以看到一个例子是如何工作的:HTTP:/ /jsfiddle.net/bygzgc9h/ –

回答

1

您可以指定该系列的颜色选项。 比方说,你要指定你的系列如:

data=[{x:10,y:12}] 

它转换为以下几点:

data=[{x:10,y:12,color:'#FFFFFF'}] 

必须添加颜色你在哪里填充系列,即,在那里你指定x /您的列的y值。

而且我发现这个答案可能是重复的,以您的问题,检查出来: set-different-colors-for-each-column-in-highcharts

+0

我在哪里可以将它放在我的代码中? – Qerjiuthn