highcharts:組合圖,生成可以點擊的橫座標

[size=medium]1.生成可以點擊的橫座標主要的chart代碼:[/size]
xAxis: {
categories: [
'一月',
'二月',
'三月',
'四月',
'五月',
'六月',
],
labels: {//生成可以點擊的<a>橫座標
formatter: function() {
//this.value的值是:一月或其他的橫座標(當前點擊的橫座標的值),showDetails爲自己寫的函數
return '<a href="javascript:showDetails(\'' + this.value +'\');">' + this.value + '</a>';
}
}
}


[size=medium]如果想點擊像柱狀圖的柱子這樣的可以在plotOptions設置:[/size]

plotOptions: {
series: {
cursor: 'pointer',
events: {
click: function() {//點擊圖上的值時會調用。this爲series
alert(this.name);
}
}
}
}


[size=medium]2.組合圖的實現主要的chart代碼:[/size]
可以在plotOptions定義對各個圖的不同樣式,操作
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
},
column: {
pointPadding: 0.2,
borderWidth: 0,
dataLabels: {
enabled: false
},
enableMouseTracking: true//啓用或禁用鼠標跟蹤特定系列。這包括點工具提示並單擊事件在圖表和點。
},
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 1) +' %';
}
},
nableMouseTracking: false
}
}


[size=medium]然後再series寫入自己的數據:
要註明type的類型: 'column','line','pie'等。[/size]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章