1
lxl
2022-10-12 1494c7949d90e1e8407b71606947dc8d9cb60778
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
<template>
  <div class="echart35_box">
    <div id="echart35"></div>
  </div>
</template>
 
<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {};
  },
  mounted() {
    this.lineChart();
  },
  //方法集合
  methods: {
    lineChart() {
      let option = {
        title: {
          text: "人员构成",
          textStyle: {
            color: "#fff",
          },
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        // legend: {},
        grid: {
          left: "0%",
          right: "4%",
          bottom: "0%",
          containLabel: true,
        },
        xAxis: {
          type: "value",
          boundaryGap: [0, 0.01],
          axisLine: {
            lineStyle: {
              color: "#ccc",
            },
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
            },
          },
        },
        yAxis: {
          type: "category",
          data: ["专科", "本科", "硕士", "博士及以上", "其他"],
          axisLine: {
            lineStyle: {
              color: "#ccc",
            },
          },
          axisLabel: {
            show: true,
            textStyle: {
              color: "#fff",
            },
          },
        },
        series: [
          {
            name: "人员构成",
            type: "bar",
            // barWidth: 20,
            data: [15, 120, 50, 40, 20],
            itemStyle: {
              normal: {
                // 柱形图圆角,初始化效果
                barBorderRadius: [0, 10, 10, 0],
                color: (params) => {
                  var colorList = [
                    ["#00FCFF", "#008297"],
                    ["#0091FF", "#005EA4"],
                    ["#901698", "#F157EE"],
                    ["#40FBCB", "#009871"],
                    ["#FF515A", "#FFDD53"],
                    ["#6574E2", "#261164"],
                  ];
                  var colorItem = colorList[params.dataIndex];
                  return new this.$echarts.graphic.LinearGradient(
                    1,
                    0,
                    0,
                    0,
                    [
                      {
                        offset: 0,
                        color: colorItem[0],
                      },
                      {
                        offset: 1,
                        color: colorItem[1],
                      },
                    ],
                    false
                  );
                },
              },
            },
          },
        ],
      };
      let myChart = this.$echarts.init(document.getElementById("echart35"));
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
  },
  created() {},
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.echart35_box {
  padding: 20px;
  // background: rgba(0, 0, 0, 0.6);
}
#echart35 {
  width: 100%;
  height: 100%;
}
</style>