用highcharts显示数据时,会有不同数据的单位不一样的问题。如下设置数据单位时会把所有数据的单位(标签)设置成一样的:
$('#charts').highcharts({
chart: {
type: 'column'
},
title: {
text: "传感器数据"
},
tooltip: {
valueSuffix: '°C'
},
plotOptions:{
column:{
dataLabels:{
enabled:true, //是否显示数据标签
formatter: function() {
return this.y + '°C';
}
}
}
},
subtitle: {
text: null,
},
xAxis: {
categories: [1,2,3,4]
},
yAxis: {
title: {
text: '值'
}
},
series: [{
name: '温度',
data: [23,21,24,20]
},{