2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
<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: "NeiWaiYouKe",
      data() {
         return {
            option1: {}
         }
      },
      components: {
         chart
      },
      mounted() {
         var comeDataSource = [30, 12, 14, 13, 19, 15, 12, 17]
         var leaveDataSource = [-20, -12, -14, -13, -19, -15, -12, -17]
         this.option1 = {
            color: ['#33eeee', '#44bbee', '#29CEFF', '#F9993A'], //依次选择颜色,默认为第一个颜色,多根柱子多个颜色
            tooltip: {
               trigger: 'axis', //触发类型;轴触发,axis则鼠标hover到一条柱状图显示全部数据,item则鼠标hover到折线点显示相应数据,
               axisPointer: {     // 坐标轴指示器,坐标轴触发有效
                  type: 'shadow' // 默认为直线,可选为:'line' | 'shadow' | 'cross' , shadow表示阴影,cross为十字准星
               },
               formatter: function (params) {
                  //params[0].marker,marker参数为提示语前面的小圆点
                  return params[0].name +
                     "<br>" + params[0].marker + "本地" + params[0].value + "万人" +
                     "<br>" + params[0].marker + "外地" + params[0].value + "万人";
               }
            },
            grid: {
               top: '0px',
               left: '0px',
               right: '0px',
               bottom: '0px', //网格图(柱状图、折线图、气泡图等)离底部的距离,也可以用像素比如10px
               containLabel: true //grid 区域是否包含坐标轴的刻度标签。false可能溢出,默认为false
            },
            xAxis: [{
 
               axisTick: {
                  show: false,
               },
               axisLine: {
                  onZero: false,
                  lineStyle: {
                     color: '#30787A',
                     width: 2
                  },
                  show: false
               },
               axisLabel: {//x轴文字的配置
                  show: true,
                  rotate: 45,
                  textStyle: {
                     color: "#c3d5f8",
                     fontSize: 12,
                     // fontWeight: 'bold'
                  }
               },
               position: 'bottom',
               type: 'category',
               data: ['小寨商业区', '大唐芙蓉园', '回民街', '钟鼓楼', '华清池', '兵马俑', '华山', '浐灞']
            }],
            yAxis: [
               {
                  name: '',
                  type: 'value',
                  axisTick: {
                     show: true,
                     inside: true,
                     length: 10,
                     lineStyle: {
                        type: 'solid',
                        with: 5,
                        color: '#c3d5f8'
                     }
                  },
                  splitLine: {
                     show: false,
                  },
                  axisLine: {
                     lineStyle: {
                        width: 2,
                        color: '#c3d5f8',
                     },
                     show: true
                  },
 
                  axisLabel: { //让x轴左边的数显示为正数
                     textStyle: {
                        color: "#c3d5f8",
                        //  fontWeight: 'bold',
                        fontSize: 18,
                     },
                     margin: 10,
                     formatter: function (v) {
                        return v > 0 ? v : -v;
                     }
                  },
                  max: 35,
                  min: -35
               },
 
            ],
            series: [
               {
                  name: '内地',
                  type: 'bar',
                  stack: '总量',
                  label: {
                     show: false,
                  },
                  barWidth: 23,
                  data: comeDataSource,
                  yAxisIndex: 0,
                  showBackground: true,
                  backgroundStyle: {
                     color: 'rgba(6,7,7,0.2)',
                  }
               },
               {
                  name: '外地',
                  type: 'bar',
                  stack: '总量',
                  barWidth: 23,
                  label: {
                     show: false, //控制柱状图是否显示数值
                  },
                  yAxisIndex: 0,
                  showBackground: true,
                  backgroundStyle: {
                     color: 'rgba(6,7,7,0.2)',
                  },
                  data: leaveDataSource
               },
 
            ]
         };
      },
   }
 
 
 
</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>