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
163
164
165
166
167
168
169
170
| <script>
| import ECharts from 'echarts';
| import BaseChart from '@/components/myCharts/BaseChart.vue';
|
| import imgSrc from '../images/batt.png';
| const colorList = ['#afa3f5', '#00d488', '#3feed4', '#3bafff', '#f1bb4c', '#1fed08', '#f04d0d'];
| export default {
| extends: BaseChart,
| props: {
| name: {
| type: String,
| default: "",
| },
| unit: {
| type: String,
| default: ""
| },
| },
| data() {
| return {}
| },
| methods: {
| fullScreen() {
| return false;
| },
| setData(data) {
| let option = this.getOption(data);
| this.setOption(option);
| },
|
| getOption(data) {
| let sData = data;
|
| let width = this.$options.chart.getWidth(),
| height = this.$options.chart.getHeight();
| let imgW = width > height ? height * .25 : width * .25;
|
| // console.log(this.$options.chart.getWidth(), this.$options.chart.getHeight(), '=====get', imgW);
| return {
| grid: {
| bottom: 150,
| left: 0,
| // right: '10%'
| right: 0
| },
| graphic: {
| elements: [{
| type: "image",
| z: 6,
| // x: 0,
| y: -100,
| style: {
| image: imgSrc,
| width: imgW / 2,
| // shadowBlur: 0,
| // shadowColor: '#000',
| // shadowOffsetX: '1',
| // shadowOffsetY: '1',
| },
| left: 'center',
| // left: '48%',
| // right: '52%',
| top: "44%",
| // top: 'middle'
| }]
| },
| legend: {
| show: false,
| orient: 'vertical',
| top: "middle",
| right: "5%",
| textStyle: {
| color: '#f2f2f2',
| fontSize: 25,
|
| },
| icon: 'roundRect'
| },
|
| series: [
| // 主要展示层的
| {
| radius: ['25%', '45%'],
| center: ['50%', '50%'],
| type: 'pie',
| itemStyle: {
| normal: {
| color: function (params) {
| return colorList[params.dataIndex % colorList.length]
| },
| borderWidth: 0,
| },
| },
| // data: [{
| // value:17,
| // name:'体育技能',
| // },]
| data: sData.map((v, i) => {
| v.label = {
| color: colorList[i % colorList.length],
| normal: {
| formatter: '{nameStyle|{b}} \n {rate|{d}% ({c})}',
| // padding: [0, -110],
| // height: 165,
| rich: {
| nameStyle: {
| fontSize: 12,
| color: colorList[i % colorList.length],
| align: 'left'
| },
| rate: {
| fontSize: 14,
| color: colorList[i % colorList.length],
| align: 'left'
| }
| }
| }
| };
| return v;
| })
| },
| // 边框的设置
| {
| radius: ['43%', '45%'],
| center: ['50%', '50%'],
| type: 'pie',
| label: {
| normal: {
| show: false
| },
| emphasis: {
| show: false
| }
| },
| labelLine: {
| normal: {
| show: false
| },
| emphasis: {
| show: false
| }
| },
| animation: false,
| tooltip: {
| show: false
| },
| itemStyle: {
| normal: {
| color: 'rgba(250,250,250,0.5)'
| }
| },
| data: [{
| value: 1,
| }],
| }
| ],
| }
| }
| },
| computed: {
| yName() {
| let unit = this.unit;
| return unit ? "Y(" + unit + ")" : "Y";
| },
| },
| mounted() {
| this.setData([]);
| }
| }
| </script>
|
|