1.引用highcharts的js
<script src="~/Content/JS/highcharts.js"></script>
- 创建放置图表的区域
<div id="container1" style="width: 100%;"></div>
- 柱状图使用总结
$('#container1').highcharts({
chart: {
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
title: "姓名",
categories: [
'张三', '李四', '王五'
],
crosshair: true,
labels: {
rotation: -15, //逆时针旋转45°,标签名称太长。
//align: 'right' //设置右对齐
//step: parseInt(data.length / 5),
//staggerLines: 1
formatter: function () {
return this.value;
}
}
},
yAxis: {
min: 0,
title: {
text: '分数统计'
}
},
credits: {
enabled: false
},
tooltip: {
// head + 每个 point + footer 拼接成完整的 table
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} 次</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
borderWidth: 0
},
series: {
animation: false
}
},
colors: [
"#f45b5b",
"#2b908f"
],
series: [{
name: '语文分数',
data: [90, 98,100]
}, {
name: '数学分数',
data: [88, 92, 96]
}]
});