123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <div :class="className" :style="{height:height,width:width}" />
- </template>
- <script>
- import * as echarts from 'echarts'
- require('echarts/theme/macarons') // echarts theme
- import resize from './mixins/resize'
- const animationDuration = 3000
- export default {
- mixins: [resize],
- props: {
- className: {
- type: String,
- default: 'chart'
- },
- width: {
- type: String,
- default: '100%'
- },
- height: {
- type: String,
- default: '300px'
- }
- },
- data() {
- return {
- chart: null
- }
- },
- mounted() {
- this.$nextTick(() => {
- this.initChart()
- })
- },
- beforeDestroy() {
- if (!this.chart) {
- return
- }
- this.chart.dispose()
- this.chart = null
- },
- methods: {
- initChart() {
- this.chart = echarts.init(this.$el, 'macarons')
- this.chart.setOption({
- title: {
- text: ''
- },
- tooltip:{trigger:'item',backgroundColor:'#f2f2f2'},
- legend: {
- data:[]
- },
- splitArea : {
- show : false,
- areaStyle : {
- color: 'rgba(255,0,0,0)', // 图表背景的颜色
- },
- },
- // 设置雷达图中间射线的颜色
- axisLine: {
- lineStyle: {
- color: 'rgba(131,141,158,.1)',
- },
- },
- splitLine : {
- show : true,
- lineStyle : {
- width : 1,
- color : 'rgba(131,141,158,.1)', // 设置网格的颜色
- },
- },
- radar: {
- // shape: 'circle',
- indicator: [
- { name: '烟雾告警', max: 65000 },
- { name: '越线告警', max: 66000 },
- { name: '徘徊告警', max: 30000 },
- { name: '陌生人告警', max: 38000 },
- { name: '火焰告警', max: 52000 },
- ]
- },
- series: [
- {
- name: 'Budget vs spending',
- type: 'radar',
- areaStyle: {
- normal: {
- width: 1,
- opacity: 0.2,
- },
- },
- data: [
- {
- value: [42000, 30800, 20000, 35000, 30000, ],
- name: 'Allocated Budget',
- // 设置区域边框和区域的颜色
- itemStyle: {
- normal: {
- color: 'rgba(255,171,43,1)',
- lineStyle: {
- color: 'rgba(255,171,43,0.17)',
- },
- },
- },
- areaStyle: {
- color: 'rgba(255,171,43,1)'
- }
- },
- ]
- }
- ]
- })
- }
- }
- }
- </script>
|