echarts.js文件下载地址:Apache ECharts

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<script src="echarts.js"></script>
		<title></title>
	</head>
	<body>
		<div id="main" style="height: 1000px;width:1000px;"></div>
		<script type="text/javascript">
			var myChart=echarts.init(document.getElementById("main"));
			var option={
				backgroundColor:'rgba(128,128,128,0.1)',
				tooltip:{formatter:"{a} <br/>{c} {b}"},
				title:{
					text:'多仪表盘实例(共四个仪表盘)',
					x:'center',y:100,
					show:true,
					offsetCenter:[50,"20%"],
					textStyle:{
						fontFamily:"黑体",
						color:"blue",
						fontSize:20,
					}
				},
				series:[
					{
						name:"速度",type:"gauge",z:3,
						radius:"35%",
						min:0,
						max:220,
						splitNumber:22,
						axisLine:{lineStyle:{width:10}},
						axisTick:{
							length:15,
							splitNumber:5,
							lineStyle:{
								color:"auto",
							},
						},
						splitLine:{length:20,lineStyle:{color:"auto",}},
						title:{textStyle:{fontWeight:'bolder',fontSize:20,fontStyle:'italic'}},
						detail:{textStyle:{fontWeight:'bolder'}},
						data:[{value:40,name:'车速(km/h)'}]
					},
					{
						name:"转速",type:"gauge",
						radius:"35%",
						center:["20%","55%"],
						min:0,
						max:7,
						endAngle:45,
						splitNumber:7,
						axisLine:{lineStyle:{width:8}},
						axisTick:{
							length:12,
							splitNumber:5,
							lineStyle:{
								color:"auto",
							},
						},
						splitLine:{length:20,lineStyle:{color:"auto",}},
						pointer:{width:5},
						title:{offsetCenter:[0,'-30%'],},
						detail:{textStyle:{fontWeight:'bolder'}},
						data:[{value:1.5,name:'转速(x1000 r/min)'}]
					},
					{
						name:"油表",type:"gauge",
						radius:"25%",
						center:["77%","50%"],
						min:0,
						max:2,
						startAngle:135,
						endAngle:45,
						splitNumber:2,
						axisLine:{lineStyle:{width:8}},
						axisTick:{
							length:10,
							splitNumber:5,
							lineStyle:{
								color:"auto",
							},
						},
						axisLabel:{
							formatter:function(v){
								switch(v+''){
									case '0':return 'E';
									case '1':return '油表';
									case '2':return 'F';
								}
							}
						},
						splitLine:{length:15,lineStyle:{color:"auto",}},
						pointer:{width:4},
						title:{show:false},
						detail:{show:false},
						data:[{value:0.5,name:'gas'}]
					},
					{
						name:"水表",type:"gauge",
						radius:"25%",
						center:["77%","50%"],
						min:0,
						max:2,
						startAngle:315,
						endAngle:225,
						splitNumber:2,
						axisLine:{lineStyle:{width:8}},
						axisTick:{show:false},
						axisLabel:{
							formatter:function(v){
								switch(v+''){
									case '0':return 'H';
									case '1':return '水表';
									case '2':return 'C';
								}
							}
						},
						splitLine:{length:15,lineStyle:{color:"auto",}},
						pointer:{width:2},
						title:{show:false},
						detail:{show:false},
						data:[{value:0.5,name:'gas'}]
					},
				]
			};
			setInterval(function(){
					option.series[0].data[0].value=(Math.random()*100).toFixed(2)-0;
					option.series[1].data[0].value=(Math.random()*7).toFixed(2)-0;
					option.series[2].data[0].value=(Math.random()*2).toFixed(2)-0;
					option.series[3].data[0].value=(Math.random()*2).toFixed(2)-0;
					myChart.setOption(option,true);
				},2000);
			myChart.setOption(option);
		</script>
	</body>
</html>
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐