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
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
<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: "DamageStatistics",
    data() {
      return {
        option1: {}
      }
    },
    components: {
      chart
    },
    mounted() {
      let btnData = ["时"], seriesData = [230, 210, 200, 360, 230, 150, 150, 230, 230, 190, 200, 360, 230, 150, 360, 230, 150, 230, 150, 150, 230, 230, 400, 210], dataX = [
        "0", "1", "2", "3", "4", "5",
        "6", "7", "8", "9", "10", "11",
        "12", "13", "14", "15", "16", "17",
        "18", "19", "20", "21", "22", "23",
      ], series = [], selected = {};
      btnData.map((item, index) => {
        if (index == 0) {
          selected[item] = true;
        } else {
          selected[item] = false;
        }
        series.push({
          name: item,
          type: "line",
          data: seriesData,
          symbol: "none",
          areaStyle: {
            //区域填充样式
            normal: {
              //线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
              color: new echarts.graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  { offset: 0, color: "rgba(61,234,255, 1)" },
                  { offset: 1, color: "rgba(61,234,255, 0)" },
                ],
                false
              ),
            },
          },
          lineStyle: {
            show: true,
            normal: {
              width: 2,
              color: {
                type: "linear",
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(0, 253, 255, 1)", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "rgba(0, 253, 255, 0.60)", // 100% 处的颜色
                  },
                ],
                globalCoord: false, // 缺省为 false
              },
              shadowColor: "rgba(72,216,191, 0.3)",
            },
          },
          smooth: true,
        });
      });
      this.option1 = {
        // backgroundColor: "#000",
        //你的代码
        tooltip: {
          trigger: "axis",
          backgroundColor: "rgba(0, 0, 0, 0.5)",
          borderColor: "transparent",
          textStyle: {
            color: "#fff",
          },
          formatter: function (a) {
            let list = [];
            let listItem = "";
            for (var i = 0; i < a.length; i++) {
              list.push(
                `${a[i].marker}${a[i].name}${a[i].seriesName}:${a[i].value}个`
              );
            }
            listItem = list.join("<br/>");
            return '<div style="padding:6px;">' + listItem + "</div>";
          },
        },
        grid: {
          top: "30px",
          right: "35px",
          left: "4px",
          bottom: "0px",
          containLabel: "true",
        },
        xAxis: [
          {
            type: "category",
            name: "/时",
            // boundaryGap: false,
            // interval: 5, // 步长
            // min: 10, // 起始
            // max: 50, // 终止
            data: dataX,
            axisLine: {
              lineStyle: {
                color: "#fff",
              },
            },
            axisTick: {
              show: false,
            },
            axisLabel: {
              formatter: "{value}",
              textStyle: {
                color: "#fff",
              },
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "单位:个",
            splitNumber: 4,
            splitLine: {
              lineStyle: {
                // type: "dashed",
                color: "rgba(255, 255, 255, 0.2)",
              },
            },
            axisLabel: {
              // formatter: "{value}",
              formatter: function (value, index) {
                // if (value >= 10000) {
                //   return value / 10000;
                // } else {
                //   return value;
                // }
                return value;
              },
              textStyle: {
                color: "#fff",
              },
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: "#fff",
              },
            },
            nameTextStyle: {
              color: "#fff",
            },
            splitArea: {
              show: false,
            },
          },
        ],
        series: series,
      };
    },
  }
 
 
 
</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>