1.首先,在https://www.hcharts.cn/下载Highcharts的组件。
2.然后,引用
<script src="../code/highcharts.js"></script>
3.html:
<div id="container" style="width: 550px; height: 400px;">
</div>
4.js
function getselect(Number_cp) {
Number_cp = $(".Number_cp").val();
$.ajax({
url: "../Ajax/DataStatistics.ashx?action=select",
type: "POST",
dataType: "text",
data: {
Number_cp: Number_cp
},
success: function (data) {
var s = data;
var model = eval(s);
a = "";
for (var i = 0; i < model.length; i++) {
var m = model[i].Quantity;
a += m + ",";
}
series_data = "";
series_data = a.substring(0, a.length - 1);
getQuantity(series_data);
}
})
}
function getQuantity(series_data) {
var chart = Highcharts.chart('container', {
chart: {
type: 'line'
},
credits: {
enabled: false //不显示LOGO
},
title: {
text: '产品数量/每月'
},
legend: {
align: 'right',
verticalAlign: 'top',
y: 60
},
xAxis: {
softMin: 1,
title: {
text: '月份'
},
categories: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
},
yAxis: {
softMax: 4000,
tickAmount: 9,
title: {
text: '产品数量'
},
},
plotOptions: {
line: {
dataLabels: {
enabled: true
},
enableMouseTracking: false
}
},
series: [{
name: '产品数量',
data: eval("[" + series_data + "]")
}],
});
}
5.效果图: