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
171
172
173
174
175
| <template>
| <div class="m-chart">
| <div class="chart-t">
| <div style="height: 370px" :id="pie"></div>
| <div style="height: 370px" :id="cli"></div>
| </div>
| </div>
| </template>
| <script>
| let echarts = require("echarts");
| export default {
| data() {
| return {
| pie: "p-" + ~~(Math.random(10000, 100000) * 100000),
| cli: "c-" + ~~(Math.random(10000, 100000) * 100000),
| text: "测试。。。。。",
| value1: "1",
| };
| },
| created() {
| console.log("model-created");
| },
| mounted() {
| let myChart = echarts.init(document.getElementById(this.cli));
| // 绘制图表
| myChart.setOption({
| title: {
| text: "Vue3从入门到放弃",
| left: "center",
| },
| tooltip: {
| trigger: "item",
| },
| legend: {
| top: 100,
| orient: "vertical",
| right: "10",
| },
| series: [
| {
| name: "访问来源",
| type: "pie",
| radius: ["40%", "75%"],
| avoidLabelOverlap: false,
| itemStyle: {
| borderRadius: 10,
| borderColor: "#fff",
| borderWidth: 2,
| },
| label: {
| show: false,
| position: "center",
| },
| emphasis: {
| label: {
| show: true,
| fontSize: "40",
| fontWeight: "bold",
| },
| },
| labelLine: {
| show: false,
| },
| data: [
| { value: 1048, name: "搜索引擎" },
| { value: 735, name: "直接访问" },
| { value: 580, name: "邮件营销" },
| { value: 484, name: "联盟广告" },
| { value: 300, name: "视频广告" },
| ],
| },
| ],
| });
|
| let myPie = echarts.init(document.getElementById(this.pie));
| myPie.setOption({
| tooltip: {
| trigger: "axis",
| axisPointer: {
| // Use axis to trigger tooltip
| type: "shadow", // 'shadow' as default; can also be 'line' or 'shadow'
| },
| },
| legend: {
| data: [
| "Direct",
| "Mail Ad",
| "Affiliate Ad",
| "Video Ad",
| "Search Engine",
| ],
| },
| grid: {
| top: 30,
| left: "3%",
| right: "4%",
| bottom: 0,
| containLabel: true,
| },
| xAxis: {
| type: "value",
| },
| yAxis: {
| type: "category",
| data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
| },
| series: [
| {
| name: "Direct",
| type: "bar",
| stack: "total",
| label: {
| show: true,
| },
| emphasis: {
| focus: "series",
| },
| data: [320, 302, 301, 334, 390, 330, 320],
| },
| {
| name: "Mail Ad",
| type: "bar",
| stack: "total",
| label: {
| show: true,
| },
| emphasis: {
| focus: "series",
| },
| data: [120, 132, 101, 134, 90, 230, 210],
| },
| {
| name: "Affiliate Ad",
| type: "bar",
| stack: "total",
| label: {
| show: true,
| },
| emphasis: {
| focus: "series",
| },
| data: [220, 182, 191, 234, 290, 330, 310],
| },
| {
| name: "Video Ad",
| type: "bar",
| stack: "total",
| label: {
| show: true,
| },
| emphasis: {
| focus: "series",
| },
| data: [150, 212, 201, 154, 190, 330, 410],
| },
| ],
| });
| },
| };
| </script>
| <style scoped>
| .m-chart {
| margin-top: 20px;
| background: white;
| border-top: 10px solid #eee;
| }
| .chart-t {
| display: flex;
| }
| .chart-t > div {
| padding: 10px;
| margin: 10px;
| flex: 1;
| }
| </style>
|
|