本文主要是介绍jquery图表插件highcharts使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当我们使用highcharts做这样的图是不是很老火,其实开始我感觉很麻烦。但是官网上有demo,虽然只有很小一部分。http://www.highcharts.com/demo/column-stacked基本百度一下就可以找到加入曲线。其实就是 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 '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'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
}
]}
]
});
});
</script>
这篇关于jquery图表插件highcharts使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!