仪表盘(highcharts)

仪表盘:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>

<div id="container" style="width: 600px; height: 300px; margin: 0 auto"></div>
js代码:
$(function () {
var colors = ['#07FD04','#FFFF00','#FF7805','#FA0100','#9E004F','#790222']
$('#container').highcharts({
chart :{
renderTo: 'container',
type: 'gauge',
plotBorderWidth: 1,
plotBackgroundColor: {//背景色
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
stops: [
[0, '#FFF4C6'],
[0.3, '#FFFFFF'],
[1, '#FFF4C6']
]
},
plotBackgroundImage: null,//背景图片
height: 210
},
title : {
text: '北京市最近24小时空气质量指数趋势(AQI)'
},

pane : [{
startAngle: -90,
endAngle: 90,
background: null,
center: ['45%', '100%'],
size: 300
}],
yAxis : [{
// tickLength:0,
// minorTickLength:0,
min: 0,
max: 500,
minorTickPosition: 'inside',
tickPosition: 'inside',
labels: {
// enabled:false,
rotation: 'auto',
distance: 10
},
plotBands: [{//分区段
from: 0,
to: 50,
color: colors[0],
innerRadius: '100%',
outerRadius: '65%'
},{
from: 50,
to: 100,
color: colors[1],
innerRadius: '100%',
outerRadius: '65%'
},{
from: 100,
to: 150,
color: colors[2],
innerRadius: '100%',
outerRadius: '65%'
},{
from: 150,
to: 200,
color: colors[3],
innerRadius: '100%',
outerRadius: '65%'
},{
from: 200,
to: 300,
color: colors[4],
innerRadius: '100%',
outerRadius: '65%'
},{
from: 300,
to: 500,
color: colors[5],
innerRadius: '100%',
outerRadius: '65%'
}],
title: {
text: 'AQI',
style :{
fontSize : '14px',
marginTop : '10px'
},
y: 20
}
}],
exporting :{
enabled: true
},
plotOptions: {
gauge: {
dataLabels: {
enabled: true,
y : -20
},
dial: {//仪表盘指针
radius: '80%',
rearLength: '0%',
backgroundColor: 'silver',
borderColor: 'silver',
borderWidth: 1,
baseWidth: 10,
topWidth: 1,
baseLength: '30%'
}
}
},
tooltip :{
formatter: function() {
var name = '';
if(this.y >= 0 && this.y <=50)
name = "优";
else if(this.y > 50 && this.y <= 100)
name = "良";
else if (this.y > 100 && this.y <=150)
name = "轻度污染";
else if(this.y > 150 && this.y <= 200)
name = "中度污染";
else if(this.y > 200 && this.y <= 300)
name = "重度污染";
else if(this.y > 300)
name = "严重污染";

return '北京市最近24小时空气质量指数趋势(AQI): '+ this.y + ", 空气质量状况:" + name;
}
},
series: [{
name : '北京市最近24小时空气质量指数趋势(AQI)',
data: [150],
yAxis: 0
}]
});
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值