直接贴上希望看到的图片和做到的图片,求大神指点
希望做到的样式
已经做到的样式
代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>当前设备合格率</title>
<script type="text/javascript" src="js/echarts.js" ></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js" ></script>
</head>
<body>
<div id="main" style=" width: 300px; height: 300px;"></div>
<script>
var mycharts = echarts.init(document.getElementById("main"));
var url = "./json/rate.json";
$.get(url).done(function(data){
var pass=data.results.pass;
var total=data.results.total;
var pass1 = parseFloat((parseFloat(pass))/parseFloat(total)).toFixed(2);
var va=10;
console.log(pass1);
option = {
viewMap: {
symbol: 'circle',
},
tooltip : {
formatter: "{a} <br/>{b} : {c}%"
},
toolbox: {
feature: {
restore: {},
saveAsImage: {}
}
},
series: [
{
name: '业务指标',
type: 'gauge',
splitNumber: 0,
axisLabel: {
show: false,
distance: 0,
},
pointer: {
show: false
},
splitLine: {
show: false,
},
axisTick : {
show: false,
},
axisLine: {
lineStyle: {
width: 20,
color: [
[pass1, '#91c7ae'],
[ 1,'#eee']
]
}
},
title : {
offsetCenter: [0, '10%'], // x, y,单位px
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: 'bolder',
fontSize: 20,
fontStyle: 'italic',
// color: '#fff',
}
},
detail : {
offsetCenter: ["-0%", '-25%'], // x, y,单位px
color:"#ff0000",
formatter: va+'%',
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: 'bolder',
// color: '#fff'
}
},
data: [
{value: 90, name:"完成率"}
]
}
]
}
mycharts.setOption(option);
})
</script>
</body>
</html>
大神做出来了没,最近一直在折磨这个东西