| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <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'
- import {procedureCount} from "@/api/common/homedataCbpb";
- const animationDuration = 3000
- export default {
- mixins: [resize],
- props: {
- className: {
- type: String,
- default: 'chart'
- },
- width: {
- type: String,
- default: '100%'
- },
- height: {
- type: String,
- default: '210px'
- }
- },
- data() {
- return {
- chart: null,
- chartData: {},
- color: [
- '#87CA8B',
- '#58B1FF',
- '#FBD44A',
- '#7485E5',
- '#AEE5B1',
- '#81C4FF',
- '#AAD7FF',
- '#FFE791',
- '#9AA6EA',
- ],
- dataIn: [
- // 外层数据
- ],
- dataOut: []
- }
- },
- created() {
- },
- mounted() {
- this.$nextTick(() => {
- procedureCount().then(res => {
- this.dataOut = [
- {value: res.data.appNum, name: res.data.app},
- {value: res.data.trainNum, name: res.data.train},
- {value: res.data.excelNum, name: res.data.excel},
- {value: res.data.fileNum, name: res.data.file},
- {value: res.data.guideNum, name: res.data.guide},
- {value: res.data.fingerpostNum, name: res.data.fingerpost}
- ]
- 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({
- color: this.color,
- tooltip: {
- trigger: 'item',
- formatter: "{b}: {c} " + " | " + "{d}%"
- },
- title:
- {
- text: '',
- }
- ,
- legend: {
- orient: 'vertical',
- left: 'left',
- itemWidth: 10,
- itemHeight: 10,
- textStyle: {
- fontSize: 12,
- padding:[0,0]
- },
- selectedMode: true,
- data: ['程序总汇', '指南总汇', '指导书总汇', '附件总汇', '表格总汇', '培训材料'],
- },
- series: [
- {
- name: '',
- type: 'pie',
- selectedMode: 'single',
- radius: ['20%', '80%'],
- label: {
- position: 'outside',
- fontSize: 10,
- },
- animationEasing: 'cubicInOut',
- animationDuration: 1300,
- labelLine: {
- show: true
- },
- data: this.dataOut
- }
- ],
- })
- }
- }
- }
- </script>
|