前言
基于echarts5.x和vue2实现
记录以便日后查阅
实现效果
代码实现
<template>
<div class="chart-wrap">
<div id="chart12" class="chart" />
div>
template>
<script>
export default {
name: 'Index',
data () {
return {
chart: null,
data1: [60, 70, 50, 80, 66, 77],
data2: [86, 83, 82, 91, 90, 87]
}
},
mounted() {
this.createChartHandler()
},
methods: {
createChartHandler () {
this.chart = this.$echarts.init(document.getElementById('chart12'))
this.chart.setOption(this.getChartOption(this.data1, this.data2))
window.addEventListener('resize', () => {
setTimeout(() => {
this.chart.resize()
})
})
},
getChartOption (data1, data2) {
return {
normal: {
top: 0,
left: 0,
width: 0,
height: 0,
zIndex: 6,
backgroundColor: ''
},
legend: {
show: false,
data: [
{
name: '上月指数',
icon: 'circle'
},
{
name: '当月指数',
icon: 'circle'
}
],
left: 'center',
position: ['bottom', 'center']
},
color: ['rgba(245, 166, 35, 1)', 'rgba(19, 173, 255, 1)'],
radar: {
center: ['50%', '50%'],
axisName: {
fontSize: 12,
color: 'rgba(221,221,221,0.79)',
formatter: function (value, indicator) {
if (value !== '安防态势' && value !== '产业经济') {
const charArr = value.split('')
return charArr[0] + charArr[1] + '\n' + charArr[2] + charArr[3]
}
return value
}
},
axisNameGap: 4,
radius: ['0%', '70%'],
splitNumber: 6,
splitArea: {
areaStyle: {
color: ['transparent']
}
},
axisLine: {
show: true,
lineStyle: {
color: 'rgba(221,221,221,0.79)'
}
},
splitLine: {
show: true,
lineStyle: {
color: 'rgba(221,221,221,0.79)'
}
},
indicator: [
{
text: '安防态势',
max: 100
},
{
text: '消防状态',
max: 100
},
{
text: '能耗监测',
max: 100
},
{
text: '产业经济',
max: 100
},
{
text: '设备运行',
max: 100
},
{
text: '环境监测',
max: 100
}
]
},
series: [
{
name: '上月指数',
type: 'radar',
symbol: 'circle',
symbolSize: 4,
areaStyle: {
color: '#06C88C'
},
itemStyle: {
color: '#06C88C'
},
lineStyle: {
type: 'dashed',
color: '#06C88C',
width: 2
},
data: [data1]
},
{
name: '当月指数',
type: 'radar',
symbol: 'circle',
symbolSize: 4,
itemStyle: {
color: '#63BCFF'
},
areaStyle: {
color: '#63BCFF'
},
lineStyle: {
color: '#63BCFF',
width: 2,
type: 'dashed'
},
data: [data2]
}
]
}
}
}
}
script>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118
- 119
- 120
- 121
- 122
- 123
- 124
- 125
- 126
- 127
- 128
- 129
- 130
- 131
- 132
- 133
- 134
- 135
- 136
- 137
- 138
- 139
- 140
- 141
- 142
- 143
- 144
- 145
- 146
- 147
- 148
- 149
- 150
- 151
- 152
- 153
- 154
- 155
- 156
- 157
- 158
- 159
- 160
- 161
- 162