以下内容仅供参考~
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Echars 折线图+仪表盘</title>
</head>
<body>
<div id="echarsID" style="height: 600px;"></div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js" type="text/javascript" charset="utf-8"></script>
<!-- echars版本可以使用自己的 -->
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.0.1/echarts.js" type="text/javascript" charset="utf-8"></script>
<script>
function showEchars() {
let myChart = echarts.init(document.getElementById('echarsID'));
let option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',//默认为line,line直线,cross十字准星,shadow阴影
crossStyle: {
color: '#999'
}
}
},
grid: { //边距
left: '4%',
right: '4%',
bottom: '3%',
top: '60%',
containLabel: true
},
legend: {
"right": "4%",
"top": '12%',
data: ["PASS"],
},
xAxis: {
type: 'category',
data: ['IPI', 'Overflow cleanong', 'Ground Tape', 'Lstrap', 'Ring Welding', 'TZ-TEK', 'Mesh-ALT'],
},
yAxis: {
type: 'value',
name: '百分比',
min: 0,
max: 100,
interval: 20,
axisLabel: {
formatter: '{value} %'
}
},
series: [{
name: "PASS",
data: [99, 89, 99, 79, 99, 96, 78],
type: 'line',
color: ["#2B6832"],
smooth: true
}, {
type: 'gauge',
startAngle: 180,
endAngle: 0,
min: 0,
radius:'80%',//控制仪表盘大小
max: 100,//设置刻度盘内数值区间
splitNumber: 10,//设置间隔区域的显示数量
axisLine: {// 坐标轴线
lineStyle: {
width: 6,
color: [
[0.25, '#FF6E76'],
[0.5, '#FDDD60'],
[0.75, '#58D9F9'],
[1, '#7CFFB2']
]
}
},
pointer: {
icon: 'path://M12.8,0.7l12,40.1H0.7L12.8,0.7z',
length: '12%',//指针长度,按照半圆半径的百分比
width: 20,//指针的宽度
offsetCenter: [0, '-60%'],
itemStyle: {
color: 'auto'
}
},
axisTick: {
length: 12,
lineStyle: {
color: 'auto',
width: 2
}
},
splitLine: {
length: 20,
lineStyle: {
color: 'auto',
width: 5
}
},
axisLabel: { // 坐标轴小标记
color: '#464646',
fontSize: 20,//改变仪表盘内刻度数字的大小
distance: -60
},
axisLabel: {
color: 'auto',
distance: 10,
fontSize: 15
},
title: {
offsetCenter: [0, '-20%'],//改变标题的位置
fontSize: 30
},
detail: {
fontSize: 50,
offsetCenter: [0, '0%'],
valueAnimation: true,
formatter: function(value) {
return value + '%';
},
color: 'auto'
},
data: [{
value: 99.71,
name: 'Cum Final Pass'
}]
}]
}
//清空
myChart.clear();
//绘制
myChart.setOption(option, true);
//自适应
window.addEventListener("resize", function() {
myChart.resize();
});
}
showEchars();
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Echars 折线图+仪表盘</title>
</head>
<body>
<div id="echarsID" style="height: 600px;"></div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js" type="text/javascript" charset="utf-8"></script>
<!-- echars版本可以使用自己的 -->
<script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.0.1/echarts.js" type="text/javascript" charset="utf-8"></script>
<script>
function showEchars() {
let myChart = echarts.init(document.getElementById('echarsID'));
let option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
grid: { //边距
left: '4%',
right: '4%',
bottom: '3%',
top: '60%',
containLabel: true
},
legend: {
"right": "4%",
"top": '12%',
data: ["PASS"],
},
xAxis: {
type: 'category',
data: ['IPI', 'Overflow cleanong', 'Ground Tape', 'Lstrap', 'Ring Welding', 'TZ-TEK', 'Mesh-ALT'],
},
yAxis: {
type: 'value',
name: '百分比',
min: 0,
max: 100,
interval: 20,
axisLabel: {
formatter: '{value} %'
}
},
series: [{
name: "PASS",
data: [99, 89, 99, 79, 99, 96, 78],
type: 'line',
color: ["#2B6832"],
smooth: true
}, {
type: 'gauge',
radius: '50%',
center: ['50%', '30%'], //位置
axisLine: {
lineStyle: {
width: 20,
color: [
[0.3, '#fd666d'],
[0.7, '#37a2da'],
[1, '#67e0e3']
]
}
},
pointer: {
itemStyle: {
color: 'auto'
}
},
axisTick: {
distance: -20,
length: 8,
lineStyle: {
color: '#fff',
width: 1
}
},
splitLine: {
distance: -40,
length: 35,
lineStyle: {
color: '#fff',
width: 3
}
},
axisLabel: {
color: 'auto',
distance: 33,
fontSize: 15
},
detail: {
valueAnimation: true,
formatter: '{value} %',
color: 'auto',
textStyle: {
fontSize: 18
}
},
title: {
show: true,
offsetCenter: [0, '-30%'], // x, y,单位px
textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
fontWeight: 'bolder',
fontSize: 12
}
},
data: [{
value: 99.71,
name: 'Cum Final Pass'
}]
}]
}
//清空
myChart.clear();
//绘制
myChart.setOption(option, true);
//自适应
window.addEventListener("resize", function() {
myChart.resize();
});
}
showEchars();
</script>
</html>