<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./echarts.js"></script>
<style>
#main {
width: 306px;
height: 278px;
}
</style>
</head>
<body>
<div id="main"></div>
<script>
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
var dataArr = 8;
option = {
backgroundColor: '#021434',
series: [{
name: '外层刻度',
type: 'gauge',
radius: '111%',
splitNumber: 10,
startAngle: 450,
endAngle: 90,
z: 5,
axisLine: {
show: false,
lineStyle: {
width: 5,
color: [
[1, '#1087e2']
],
}
},
axisLabel: {
show: false
},
axisTick: {
show: true,
splitNumber: 10,
lineStyle: {
color: 'rgba(0,255,255,0.5)',
width: 3
},
length: 13
},
splitLine: {
show: false,
},
detail: {
show: false
},
pointer: {
show: false
}
},
// {
// name: "最外层圆环",
// type: "gauge",
// radius: '100%',
// splitNumber: 10,
// endAngle: '-269.9999',
// startAngle: '90',
// axisLine: {
// lineStyle: {
// color: [
// [1, new echarts.graphic.LinearGradient(
// 0, 1, 0, 0, [{
// offset: 0,
// color: 'rgba(0,255,255,0)',
// }, {
// offset: 0.5,
// color: 'rgba(0,255,255,1)',
// }, {
// offset: 1,
// color: 'rgba(0,255,255,0)',
// }]
// )],
// [
// 1, 'rgba(28,128,245,.0)'
// ]
// ],
// width: 12
// },
// },
// axisLabel: {
// show: false,
// },
// axisTick: {
// show: false,
// },
// splitLine: {
// show: false,
// },
// },
{
name: "最外部进度条",
type: "gauge",
radius: '80%',
splitNumber: 10,
axisLine: {
lineStyle: {
color: [
[1, new echarts.graphic.LinearGradient(
0, 1, 0, 0, [{
offset: 0,
color: 'rgba(0,255,255,0)',
}, {
offset: 0.5,
color: 'rgba(0,255,255,0.3)',
}, {
offset: 1,
color: 'rgba(0,255,255,0)',
}]
)],
[
1, 'rgba(0,255,255,.0)'
]
],
width: 5
},
},
axisLabel: {
show: false,
},
axisTick: {
show: false,
},
splitLine: {
show: false,
},
}, {
name: "内部阴影",
type: "gauge",
radius: '70%',
z: 3,
splitNumber: 10,
axisLine: {
lineStyle: {
color: [
[dataArr / 10, new echarts.graphic.LinearGradient(
0, 1, 0, 0, [{
offset: 0,
color: 'rgba(0,255,255,0)',
}, {
offset: 0.5,
color: 'rgba(0,255,255,0.1)',
}, {
offset: 1,
color: 'rgba(0,255,255,1)',
}]
)],
[
1, 'rgba(28,128,245,.0)'
]
],
width: 45,
}
},
axisLabel: {
show: false,
},
axisTick: {
show: false,
},
splitLine: {
show: false,
},
itemStyle: {
show: false,
},
detail: {
formatter: function(value) {
if (value !== 0) {
return parseInt(value);
} else {
return 0;
}
},
offsetCenter: [0, 5],
textStyle: {
fontSize: 14,
color: 'white'
}
},
title: { //标题
show: false,
},
data: [{
name: 'title',
value: dataArr,
}],
pointer: {
show: false,
},
}, {
name: '内部圈',
type: 'gauge',
z: 2,
min: 0,
max: 10,
splitNumber: 10,
radius: '70%',
axisLine: {
lineStyle: {
color: [
[1, 'rgba(0,255,255)']
],
width: 6,
shadowColor: 'rgba(0,255,255,.5)',
shadowBlur: 10,
shadowOffsetX: 0,
}
},
tooltip: {
show: false
},
axisLabel: {
show: false,
},
axisTick: {
show: false,
},
splitLine: {
show: false,
},
itemStyle: {
show: false,
},
detail: {
show: false
},
title: { //标题
show: false,
},
data: [{
name: "title",
value: dataArr,
}],
itemStyle: {
normal: {
color: '#01f4f7'
}
},
pointer: {
show: true,
length: '80%',
radius: '20%',
width: 10, //指针粗细
},
// animationDuration: 4000,
}, {
name: '内部刻度',
type: 'gauge',
radius: '75%',
min: 0, //最小刻度
max: 10, //最大刻度
splitNumber: 10, //刻度数量
startAngle: 225,
endAngle: -45,
axisLine: {
show: false,
lineStyle: {
width: 5,
color: [
[1, 'white']
],
}
}, //仪表盘轴线
axisLabel: {
show: true,
color: 'rgba(172,207,255,.5)',
distance: 8,
fontSize: 8,
formatter: function(v) {
switch (v + '') {
case '0':
return '0';
case '1':
return '1';
case '2':
return '2';
case '3':
return '3';
case '4':
return '4';
case '5':
return '5';
case '6':
return '6';
case '7':
return '7';
case '8':
return '8';
case '9':
return '9';
case '10':
return '10';
}
}
}, //刻度标签。
axisTick: {
show: true,
splitNumber: 7,
lineStyle: {
color: "rgba(0,255,255,0.5)", //用颜色渐变函数不起作用
width: 1,
},
length: 4
}, //刻度样式
splitLine: {
show: true,
length: 8,
lineStyle: {
color: 'rgba(0,255,255,0.5)', //用颜色渐变函数不起作用
}
}, //分隔线样式
detail: {
show: false
},
pointer: {
show: false
}
}, { //指针上的圆
type: 'pie',
tooltip: {
show: false
},
hoverAnimation: false,
legendHoverLink: false,
radius: ['0%', '20%'],
center: ['50%', '50%'],
label: {
normal: {
show: false
}
},
labelLine: {
normal: {
show: false
}
},
data: [{
value: 100,
itemStyle: {
normal: {
color: "#0c244a",
},
},
}]
}, { //指针上的圆
type: 'pie',
radius: ['19%', '20%'],
center: ['50%', '50%'],
label: {
normal: {
show: false
}
},
data: [{
value: 100,
itemStyle: {
normal: {
color: "#00ffff",
},
},
}],
}
]
}
option && myChart.setOption(option);
</script>
</body>
</html>
echarts 科技仪表盘
最新推荐文章于 2024-10-17 16:54:35 发布