jquery圖表外掛highcharts使用?

Tags: 外掛, 圖表,

當我們使用highcharts做這樣的圖是不是很老火,其實開始我感覺很麻煩。但是官網上有demo,雖然只有很小一部分。基本百度一下就可以找到加入曲線。其實就是 serese 的資料,只是加入type屬性就更改成你想要的。下面那個table你可以使用table加入jquery實現就ok了

$(function () {

$('#container').highcharts({

chart: {

type: 'column'

},

title: {

text: 'Stacked column chart'

},

xAxis: {

gridLineWidth:1,

plotOptions: {

column: {

pointPadding: 0.2,

pointWidth: 30 //柱子的寬度30px

}

},

//tickPixelInterval:100,

categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']

},

yAxis: {

tickPositions: [0, 100, 200, 300, 400,500],//設定刻度

min: 0,

title: {

text: 'Total fruit consumption'

},

stackLabels: {

enabled: true,

style: {

fontWeight: 'bold',

color: (Highcharts.theme && Highcharts.theme.textColor) 'gray'

}

}

},

legend: {

align: 'right',

x: -100,

verticalAlign: 'top',

y: 20,

floating: true,

backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) 'white',

borderColor: '#CCC',

borderWidth: 1,

shadow: false

},

tooltip: {

formatter: function() {

return ''+ this.x +'
'+

this.series.name +': '+ this.y +'
'+

'Total: '+ this.point.stackTotal;

}

},

plotOptions: {

column: {

stacking: 'normal',

pointWidth: 30 , //柱子的寬度30px

dataLabels: {

enabled: true,

color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) 'white'

}

}

},

series: [{

color:'#F2BE20',

name: 'John',

data: [50, 30, 40, 70, 20]

}, {

color:'#F8FB23',

name: 'Jane',

data: [20, 20, 30, 20, 10]

}, {

color:'#E9070B',

name: 'Joe',

data: [30, 40, 40, 20, 50]

},{type: 'line',

name: 'John',

data:[{

name: 'John',

y: 50

},

{

name: 'John',

y: 30

},

{

name: 'John',

y: 40

},{

name: 'John',

y: 70

},{

name: 'John',

y: 20

}

]},

{type: 'line',

name: 'Joe',

data:[{

name: 'Joe',

y: 30

},

{

name: 'Joe',

y: 40

},

{

name: 'Joe',

y: 40

},{

name: 'Joe',

y: 20

},{

name: 'Joe',

y: 50

}

]},

{type: 'line',

name: 'Jane',

data:[{

name: 'Jane',

y: 20

},

{

name: 'Jane',

y: 20

},

{

name: 'Jane',

y: 30

},{

name: 'Jane',

y: 20

},{

name: 'Jane',

y: 10

}

]}

]

});

});

相關問題答案