longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
<script>
import ECharts from "echarts";
import BaseChart from "@/components/myCharts/BaseChart";
export default {
  name: "DivideGradientBar",
  extends: BaseChart,
  props: {
    name: {
      type: String,
      default: "",
    },
    unit: {
      type: String,
      default: ""
    },
  },
  data() {
    return {}
  },
  methods: {
    setData(data) {
      let option = this.getOption(data);
      this.setOption(option);
    },
    getOption(data) {
      let xLabel = data.xLabel;
      let sData = data.sData;
      let sName = this.name;
      let yName = this.yName;
      let min = sData.length == 0?0:null;
      let max = sData.length == 0?0:null;
 
      return {
        animation: false,
        tooltip:{},
        grid: {
          top: "28px",
          left: '1%',
          right: '1%',
          bottom: '8px',
          containLabel: true
        },
        xAxis: {
          data: xLabel,
        },
        yAxis: [
          {
            name: yName,
            type: "value",
            min: min,
            max: max,
            splitLine: {
              show: true
            }
          },
        ],
        series: [
          {
            name: sName,
            type: "bar",
            barWidth: '50%',
            data: sData,
            itemStyle: {
              normal: {
                color: new ECharts.graphic.LinearGradient(0, 0, 0, 1, [{
                  offset: 0,
                  color: 'rgba(0,244,255,1)' // 0% 处的颜色
                }, {
                  offset: 1,
                  color: 'rgba(0,77,167,1)' // 100% 处的颜色
                }], false),
                shadowColor: 'rgba(0,160,221,1)',
                shadowBlur: 4,
              }
            },
            label: {
              show: true,
              position: "top",
              distance: 10,
              fontSize: 12,
              color: "#FFFFFF"
            }
          },
        ]
      }
    }
  },
  computed: {
    yName() {
      let unit = this.unit;
      return unit?"Y("+unit+")": "Y";
    },
  },
  mounted() {
    this.setData({
      xLabel: [],
      sData: [],
    });
  }
}
</script>