123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <template>
- <div id="mark-prog-pie"></div>
- </template>
- <script>
- import elementResizeDetectorMaker from "element-resize-detector"
- export default {
- props: {
- count: {
- type: Array,
- default: () => {
- return [0, 0, 0]
- }
- }
- },
- data() {
- return {
- techScoreGau: undefined,
- option: {
- // title: {
- // text: '阅卷进度',
- // left: 'center',
- // textStyle: {
- // color: '#ddd',
- // fontSize: 12
- // }
- // },
- tooltip: {
- trigger: 'item',
- // formatter: '{a} <br/>{b} : {c} ({d}%)'
- formatter: '{b} : {c} ({d}%)'
- },
- legend: {
- top: 10,
- itemWidth: 10,
- itemHeight: 10,
- left: 'center',
- data: ['已阅', '进行中', '未阅'],
- textStyle: {
- color: '#ddd',
- fontSize: 11,
- },
- },
- series: [
- {
- type: 'pie',
- radius: '75%',
- center: ['50%', '60%'],
- selectedMode: 'single',
- data: [
- {
- value: 0,
- name: '已阅',
- itemStyle: {
- color: "#9ff080"
- },
- },
- {
- value: 0,
- name: '进行中',
- itemStyle: {
- color: "#5c7bd9"
- },
- },
- {
- value: 0,
- name: '未阅',
- itemStyle: {
- color: "#ffdc60"
- },
- }
- ],
- label: {
- show: false
- },
- emphasis: {
- itemStyle: {
- shadowBlur: 10,
- shadowOffsetX: 0,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- }
- }
- ]
- }
- }
- },
- mounted() {
- this.techScoreGau = this.$echarts.init(document.getElementById('mark-prog-pie'))
- this.techScoreGau.setOption(this.option)
- this.erd = elementResizeDetectorMaker()
- this.erd.listenTo(document.getElementById("mark-prog-pie"), () => {
- this.$nextTick(() => {
- //监听到事件后执行的业务逻辑
- this.techScoreGau.resize()
- })
- })
- },
- watch: {
- count: {
- handler(n, o) {
- this.count.forEach((item, index) => {
- console.log(item, index)
- this.option.series[0].data[index].value = item
- })
- if (!this.techScoreGau) {
- this.$nextTick(() => {
- this.techScoreGau = this.$echarts.init(document.getElementById('mark-prog-pie'))
- this.techScoreGau.setOption(this.option)
- })
- } else {
- this.techScoreGau.setOption(this.option)
- }
- },
- immediate: true,
- deep: true
- }
- }
- }
- </script>
- <style lang="less" scoped>
- #mark-prog-pie {
- width: 400px;
- height: 200px;
- }
- </style>
- <style>
- </style>
|