|
@@ -0,0 +1,328 @@
|
|
|
|
+<template>
|
|
|
|
+ <div class="echarts">
|
|
|
|
+ <div ref="echarts1" class="echarts1"></div>
|
|
|
|
+ <div ref="echarts2" class="echarts1"></div>
|
|
|
|
+ <div ref="echarts3" class="echarts1"></div>
|
|
|
|
+ <div ref="echarts4" class="echarts1"></div>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+<style scoped lang="scss">
|
|
|
|
+.echarts {
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-between;
|
|
|
|
+ align-items: center;
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
+ .echarts1 {
|
|
|
|
+ height: 15vh;
|
|
|
|
+ width: 50%;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|
|
|
|
+<script setup>
|
|
|
|
+import * as echarts from 'echarts'
|
|
|
|
+const echarts1 = ref()
|
|
|
|
+const echarts2 = ref()
|
|
|
|
+const echarts3 = ref()
|
|
|
|
+const echarts4 = ref()
|
|
|
|
+const type = inject('type')
|
|
|
|
+// 接口
|
|
|
|
+import { UtilStore } from '@/store/api/util'
|
|
|
|
+const utilStore = UtilStore()
|
|
|
|
+const list = ref([])
|
|
|
|
+onMounted(async () => {
|
|
|
|
+ await search()
|
|
|
|
+ await echarts1View()
|
|
|
|
+ await echarts2View()
|
|
|
|
+ await echarts3View()
|
|
|
|
+ await echarts4View()
|
|
|
|
+})
|
|
|
|
+const search = async () => {
|
|
|
|
+ let res = await utilStore.one({ type })
|
|
|
|
+ if (res.errcode == '0') list.value = res.data
|
|
|
|
+}
|
|
|
|
+function echarts1View() {
|
|
|
|
+ const myChart1 = echarts.init(echarts1.value)
|
|
|
|
+ const option1 = {
|
|
|
|
+ grid: {
|
|
|
|
+ left: '0%',
|
|
|
|
+ top: '20%',
|
|
|
|
+ right: '0%',
|
|
|
|
+ bottom: '0%',
|
|
|
|
+ containLabel: true
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ subtext: list.value[0].name,
|
|
|
|
+ left: 'center',
|
|
|
|
+ bottom: 15,
|
|
|
|
+ subtextStyle: {
|
|
|
|
+ color: 'rgba(255,255,255,.6)',
|
|
|
|
+ fontSize: 12
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '',
|
|
|
|
+ type: 'gauge',
|
|
|
|
+ radius: '90%',
|
|
|
|
+ startAngle: 200,
|
|
|
|
+ endAngle: -20,
|
|
|
|
+ detail: { formatter: '{value}', offsetCenter: [0, 1], color: '#fff', fontSize: 16 },
|
|
|
|
+ data: list.value[0].data,
|
|
|
|
+ axisLine: {
|
|
|
|
+ lineStyle: {
|
|
|
|
+ width: 10,
|
|
|
|
+ color: [
|
|
|
|
+ [
|
|
|
|
+ list.value[0].percentage,
|
|
|
|
+ new echarts.graphic.LinearGradient(0, 0, 1, 0, [
|
|
|
|
+ {
|
|
|
|
+ offset: 0,
|
|
|
|
+ color: '#ae3df6'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ offset: 1,
|
|
|
|
+ color: '#53bef9'
|
|
|
|
+ }
|
|
|
|
+ ])
|
|
|
|
+ ],
|
|
|
|
+ [1, '#1c4e85']
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pointer: {
|
|
|
|
+ show: false, //不显示指针
|
|
|
|
+ length: '70%',
|
|
|
|
+ width: 3
|
|
|
|
+ },
|
|
|
|
+ axisLabel: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ splitLine: {
|
|
|
|
+ show: false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ myChart1.setOption(option1)
|
|
|
|
+ window.addEventListener('resize', function () {
|
|
|
|
+ myChart1.resize()
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+function echarts2View() {
|
|
|
|
+ const myChart2 = echarts.init(echarts2.value)
|
|
|
|
+ const option2 = {
|
|
|
|
+ grid: {
|
|
|
|
+ left: '0%',
|
|
|
|
+ top: '20%',
|
|
|
|
+ right: '0%',
|
|
|
|
+ bottom: '0%',
|
|
|
|
+ containLabel: true
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ subtext: list.value[1].name,
|
|
|
|
+ left: 'center',
|
|
|
|
+ bottom: 15,
|
|
|
|
+ subtextStyle: {
|
|
|
|
+ color: 'rgba(255,255,255,.6)',
|
|
|
|
+ fontSize: 12
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '',
|
|
|
|
+ type: 'gauge',
|
|
|
|
+ radius: '90%',
|
|
|
|
+ startAngle: 200,
|
|
|
|
+ endAngle: -20,
|
|
|
|
+ detail: { formatter: '{value}', offsetCenter: [0, 1], color: '#fff', fontSize: 16 },
|
|
|
|
+ data: list.value[1].data,
|
|
|
|
+ axisLine: {
|
|
|
|
+ lineStyle: {
|
|
|
|
+ width: 10,
|
|
|
|
+ color: [
|
|
|
|
+ [
|
|
|
|
+ list.value[1].percentage,
|
|
|
|
+ new echarts.graphic.LinearGradient(0, 0, 1, 0, [
|
|
|
|
+ {
|
|
|
|
+ offset: 0,
|
|
|
|
+ color: '#1db0d2'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ offset: 1,
|
|
|
|
+ color: '#44ceef'
|
|
|
|
+ }
|
|
|
|
+ ])
|
|
|
|
+ ],
|
|
|
|
+ [1, '#1c4e85']
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pointer: {
|
|
|
|
+ show: false, //不显示指针
|
|
|
|
+ length: '70%',
|
|
|
|
+ width: 3
|
|
|
|
+ },
|
|
|
|
+ axisLabel: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ splitLine: {
|
|
|
|
+ show: false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ myChart2.setOption(option2)
|
|
|
|
+ window.addEventListener('resize', function () {
|
|
|
|
+ myChart2.resize()
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+function echarts3View() {
|
|
|
|
+ const myChart3 = echarts.init(echarts3.value)
|
|
|
|
+ const option3 = {
|
|
|
|
+ grid: {
|
|
|
|
+ left: '0%',
|
|
|
|
+ top: '20%',
|
|
|
|
+ right: '0%',
|
|
|
|
+ bottom: '0%',
|
|
|
|
+ containLabel: true
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ subtext: list.value[2].name,
|
|
|
|
+ left: 'center',
|
|
|
|
+ bottom: 15,
|
|
|
|
+ subtextStyle: {
|
|
|
|
+ color: 'rgba(255,255,255,.6)',
|
|
|
|
+ fontSize: 12
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '',
|
|
|
|
+ type: 'gauge',
|
|
|
|
+ radius: '90%',
|
|
|
|
+ startAngle: 200,
|
|
|
|
+ endAngle: -20,
|
|
|
|
+ detail: { formatter: '{value}', offsetCenter: [0, 1], color: '#fff', fontSize: 16 },
|
|
|
|
+ data: list.value[2].data,
|
|
|
|
+ axisLine: {
|
|
|
|
+ lineStyle: {
|
|
|
|
+ width: 10,
|
|
|
|
+ color: [
|
|
|
|
+ [
|
|
|
|
+ list.value[2].percentage,
|
|
|
|
+ new echarts.graphic.LinearGradient(0, 0, 1, 0, [
|
|
|
|
+ {
|
|
|
|
+ offset: 0,
|
|
|
|
+ color: '#1ea899'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ offset: 1,
|
|
|
|
+ color: '#29c582'
|
|
|
|
+ }
|
|
|
|
+ ])
|
|
|
|
+ ],
|
|
|
|
+ [1, '#1c4e85']
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pointer: {
|
|
|
|
+ show: false, //不显示指针
|
|
|
|
+ length: '70%',
|
|
|
|
+ width: 3
|
|
|
|
+ },
|
|
|
|
+ axisLabel: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ splitLine: {
|
|
|
|
+ show: false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ myChart3.setOption(option3)
|
|
|
|
+ window.addEventListener('resize', function () {
|
|
|
|
+ myChart3.resize()
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+function echarts4View() {
|
|
|
|
+ const myChart4 = echarts.init(echarts4.value)
|
|
|
|
+ const option4 = {
|
|
|
|
+ grid: {
|
|
|
|
+ left: '0%',
|
|
|
|
+ top: '20%',
|
|
|
|
+ right: '0%',
|
|
|
|
+ bottom: '0%',
|
|
|
|
+ containLabel: true
|
|
|
|
+ },
|
|
|
|
+ title: {
|
|
|
|
+ subtext: list.value[3].name,
|
|
|
|
+ left: 'center',
|
|
|
|
+ bottom: 15,
|
|
|
|
+ subtextStyle: {
|
|
|
|
+ color: 'rgba(255,255,255,.6)',
|
|
|
|
+ fontSize: 12
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ series: [
|
|
|
|
+ {
|
|
|
|
+ name: '',
|
|
|
|
+ type: 'gauge',
|
|
|
|
+ radius: '90%',
|
|
|
|
+ startAngle: 200,
|
|
|
|
+ endAngle: -20,
|
|
|
|
+ detail: { formatter: '{value}', offsetCenter: [0, 1], color: '#fff', fontSize: 16 },
|
|
|
|
+ data: list.value[3].data,
|
|
|
|
+ axisLine: {
|
|
|
|
+ lineStyle: {
|
|
|
|
+ width: 10,
|
|
|
|
+ color: [
|
|
|
|
+ [
|
|
|
|
+ list.value[3].percentage,
|
|
|
|
+ new echarts.graphic.LinearGradient(0, 0, 1, 0, [
|
|
|
|
+ //0.8值为颜色显示百分比80%
|
|
|
|
+ {
|
|
|
|
+ offset: 0,
|
|
|
|
+ color: '#e6658f'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ offset: 1,
|
|
|
|
+ color: '#f8a58b'
|
|
|
|
+ }
|
|
|
|
+ ])
|
|
|
|
+ ],
|
|
|
|
+ [1, '#1c4e85']
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ pointer: {
|
|
|
|
+ show: false, //不显示指针
|
|
|
|
+ length: '70%',
|
|
|
|
+ width: 3
|
|
|
|
+ },
|
|
|
|
+ axisLabel: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: false
|
|
|
|
+ },
|
|
|
|
+ splitLine: {
|
|
|
|
+ show: false
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ myChart4.setOption(option4)
|
|
|
|
+ window.addEventListener('resize', function () {
|
|
|
|
+ myChart4.resize()
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+</script>
|