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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
| <template>
| <div class="publicToilets">
| <div class="header">
| <span class="title1">本省景点访问人数</span>
| </div>
| <div class="echartsTool">
| <chart :optionIn="option1" />
| </div>
| </div>
| </template>
|
| <script>
| import * as echarts from 'echarts';
| import chart from "@/components/chart.vue";
| export default {
| name: "VisitingScenicSpots",
| data() {
| return {
| option1: {}
| }
| },
| components: {
| chart
| },
| mounted() {
| this.option1 = {
| tooltip: {
| trigger: "axis",
| backgroundColor: "rgba(0,0,0,.6)",
| borderColor: "rgba(147, 235, 248, 0)",
| textStyle: {
| color: "#FFF",
| },
| axisPointer: {
| type: "none",
| },
| },
| grid: {
| left: "25px",
| top: "30px",
| right: "25px",
| bottom: "25px",
| },
| xAxis: {
| data: [
| "大雁塔",
| "回民街",
| "钟鼓楼",
| "兵马俑",
| "大唐芙\n蓉园",
| "小寨商\n业区",
| "其他",
|
| ],
| axisLine: {
| show: true, //隐藏X轴轴线
| lineStyle: {
| color: "#ccc",
| width: 1,
| },
| },
| axisTick: {
| show: false, //隐藏X轴刻度
| alignWithLabel: true,
| },
| axisLabel: {
| show: true,
| textStyle: {
| color: "#BDD8FB", //X轴文字颜色
| fontSize: 12,
| },
| interval: 0,
| formatter: function (value) {
| var ret = ""; //拼接加\n返回的类目项
| var maxLength = 4; //每项显示文字个数
| var valLength = value.length; //X轴类目项的文字个数
| var rowN = Math.ceil(valLength / maxLength); //类目项需要换行的行数
| if (rowN > 1) {
| //如果类目项的文字大于5,
| for (var i = 0; i < rowN; i++) {
| var temp = ""; //每次截取的字符串
| var start = i * maxLength; //开始截取的位置
| var end = start + maxLength; //结束截取的位置
| //这里也可以加一个是否是最后一行的判断,但是不加也没有影响,那就不加吧
| temp = value.substring(start, end) + "\n";
| ret += temp; //凭借最终的字符串
| }
| return ret;
| } else {
| return value;
| }
| },
| },
| },
| yAxis: [
| {
| type: "value",
| name: "万/人次",
| nameTextStyle: {
| color: "#BDD8FB",
| fontSize: 12,
| },
|
| splitLine: {
| show: false,
| lineStyle: {
| color: "rgba(152, 245, 255, 0.15)",
| // type: 'dashed', // dotted 虚线
| },
| },
| axisTick: {
| show: false,
| },
| axisLine: {
| show: true, //隐藏X轴轴线
| lineStyle: {
| color: "#ccc",
| width: 1,
| },
| },
| axisLabel: {
| show: true,
| textStyle: {
| color: "#BDD8FB",
| fontSize: 12,
| },
| },
| },
| {
| type: "value",
| name: "",
| nameTextStyle: {
| color: "#BDD8FB",
| fontSize: 12,
| },
| splitLine: {
| show: false,
| lineStyle: {
| width: 1,
| color: "#CED2DB",
| },
| },
| axisTick: {
| show: false,
| },
| axisLine: {
| show: false, //隐藏X轴轴线
| lineStyle: {
| color: "#163a5f",
| width: 2,
| },
| },
| axisLabel: {
| show: false,
| textStyle: {
| color: "#797A7F",
| fontSize: 12,
| },
| },
| },
| ],
| series: [
| {
| name: "访问人数",
| type: "bar",
| barWidth: 15,
| itemStyle: {
| color: {
| type: 'linear',
| x: 0, //右
| y: 0, //下
| x2: 0, //左
| y2: 1, //上
| colorStops: [
| {
| offset: 0.1,
| color: '#13D5FC' // 0% 处的颜色
| },
| {
| offset: 1,
| color: '#2059B8' // 100% 处的颜色
| }
| ]
| },
| barBorderRadius: [20, 20, 20, 20],
| },
| label: {
| show: true,
| position: "top",
| distance: 0,
| color: "#1ACDDC",
| formatter: "{c}",
| },
| data: [10.45, 8.44, 12.36, 2.33, 15.61, 13.21, 10.66],
| },
| {
| // name: '背景',
| type: "bar",
| barWidth: "15px",
| xAxisIndex: 0,
| yAxisIndex: 1,
| barGap: "-110%",
| data: [100, 100, 100, 100, 100, 100, 100], //背景阴影长度
| itemStyle: {
| normal: {
| color: "rgba(255,255,255,0.039)",
| barBorderRadius: [20, 20, 20, 20],
| },
| },
| tooltip: {
| show: false,
| },
| zlevel: 9,
| },
| ],
| };
| // var chartDom = document.getElementById('echartsTool1112');
| // var myChart = echarts.init(chartDom);
| // this.option1 && myChart.setOption(this.option1);
| },
| }
|
|
|
| </script>
|
| <style lang="scss" scoped>
| .publicToilets {
| width: 100%;
| height: 33%;
| display: flex;
| flex-direction: column;
| align-items: center;
|
| .echartsTool {
| width: calc(100% - 40px);
| height: 100%;
| margin-top: 20px;
| }
|
| .header {
| width: 304px;
| height: 27.5px;
| margin-left: 20px;
| margin-top: 20px;
| background-image: url("~@/assets/img/menuTitle1.png");
| background-repeat: no-repeat;
| background-size: 100% 100%;
| font-family: PangMenZhengDao;
| text-shadow: 0px 6px 9px #20618e;
| display: flex;
| flex-direction: row;
| align-items: center;
| flex-shrink: 0;
| align-self: flex-start;
|
| .title1 {
| margin-left: 30px;
| font-size: 15px;
| color: #ffffff;
| }
| }
| }
| </style>
|
|