1
Surpriseplus
2022-09-16 8d1a91c23df335b090e38b2edd15203aa3b03da9
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
<template>
  <div class="left3">
    <div class="title">
      <span>人口分析</span>
      <img class="img" src="../../../assets/img/zonlan (9).png" alt="" />
    </div>
    <div id="content"></div>
  </div>
</template>
 
<script>
import * as echarts from "echarts";
export default {
  name: "left3",
  mounted() {
    this.echarts3();
  },
  methods: {
    echarts3() {
      var chartDom = document.getElementById("content");
      var myChart = echarts.init(chartDom);
      var option;
 
      option = {
        title: {
          text: "人口发展情况",
          top: "-50px",
          textStyle: {
            color: "#fff",
            fontSize: 36,
          },
        },
        tooltip: {
          trigger: "axis",
          textStyle: {
            color: "#fff",
            fontSize: 36,
          },
        },
        legend: {
          itemWidth: 15,
          itemHeight: 10,
          left: "center",
          textStyle: {
            fontSize: 32,
            color: "#fff",
          },
          data: ["出生率", "死亡率", "自然增长率"],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "21%",
          height: "75%",
          containLabel: true,
        },
        toolbox: {
          feature: {
            // dataView: { show: true, readOnly: false },
            magicType: { show: true, type: ["bar"] },
            restore: { show: true },
            saveAsImage: { show: true },
          },
        },
 
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: [
            "2009",
            "2010",
            "2011",
            "2012",
            "2013",
            "2014",
            "2015",
            "2016",
            "2017",
            "2018",
            "2019",
            "2020",
          ],
          axisLabel: {
            margin: 5,
            textStyle: {
              fontSize: 24,
              color: "#B5B5B5", //设置x轴标签文字颜色
            },
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: "#B5B5B5", //设置轴线颜色
            },
          },
        },
        yAxis: [
          {
            type: "value",
            splitLine: { show: false }, //去除网格线
            splitNumber: "6",
            axisLabel: {
              margin: 0, //设置y轴标签名称与轴线间距
              textStyle: {
                fontSize: 32,
                color: "#B5B5B5", //设置y轴标签文字颜色
              },
            },
            axisLine: {
              //设置y轴轴线样式
              show: true,
              lineStyle: {
                color: "#56626E", //设置轴线颜色
              },
            },
            max: 80,
            min: -80,
          },
        ],
 
        series: [
          {
            name: "出生率",
            type: "line",
            stack: "总量",
            data: [20, 12, 35, 22, 8, 10, 22, 5, 36, 15, 34, 10],
            itemStyle: {
              normal: {
                color: "#D4BE10", //改变折线点的颜色
                lineStyle: {
                  color: "#D4BE10", //改变折线颜色
                },
              },
            },
          },
          {
            name: "死亡率",
            type: "line",
            stack: "总量",
            data: [10, 25, 5, 12, 30, 32, 10, 5, 25, 6, 31, 39],
            itemStyle: {
              normal: {
                color: "#01EE6A", //改变折线点的颜色
                lineStyle: {
                  color: "#01EE6A", //改变折线颜色
                },
              },
            },
          },
          {
            name: "自然增长率",
            type: "line",
            stack: "总量",
            data: [-20, -22, -2, -14, -20, -3, -20, -12, -15, -30, -10, -32],
            itemStyle: {
              normal: {
                color: "#00EAFF", //改变折线点的颜色
                lineStyle: {
                  color: "#00EAFF", //改变折线颜色
                },
              },
            },
          },
        ],
      };
 
      option && myChart.setOption(option);
    },
  },
};
</script>
 
<style lang="less" scoped>
.left3 {
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  height: 32%;
 
  .title {
    width: 100%;
    position: relative;
    img {
      width: 100%;
    }
    span {
      font-size: 75px;
      font-weight: 400;
      color: #ffe86b;
      background: linear-gradient(0deg, #bce7ff 0%, #69efff 98.6572265625%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      position: absolute;
      left: 50%;
      top: 0;
      transform: translateX(-50%);
    }
  }
  #content {
    width: 100%;
    height: 100%;
    top: 8%;
  }
}
</style>