CustomerAnalyse.vue 2.89 KB
Newer Older
1
<template>
潘际乾 committed
2 3 4
  <div class="home-cell" id="customerAnalyse">
    <CellHeaderVue title="大客户分析">
      <span class="el-icon-refresh" title="刷新"></span>
潘际乾 committed
5
      <span class="el-icon-more" title="操作"></span>
潘际乾 committed
6 7
    </CellHeaderVue>
    <div class="cell-content">
8 9 10 11
      <div class="chart-operate">
        <i class="el-icon-arrow-up"></i>
        <i class="el-icon-arrow-down"></i>
      </div>
潘际乾 committed
12 13 14
      <div id="chartWrapper">
        <div id="chart"></div>
      </div>
15 16 17 18 19
    </div>
  </div>
</template>

<script>
潘际乾 committed
20
import CellHeaderVue from "./CellHeader.vue";
21 22 23 24
import * as echarts from "echarts";

export default {
  name: "CustomerAnalyse",
潘际乾 committed
25
  components: { CellHeaderVue },
26
  data() {
潘际乾 committed
27 28 29
    return {
      echartInstance: null,
    };
30 31
  },
  mounted() {
潘际乾 committed
32 33 34 35 36 37 38 39 40 41 42
    this.echartInstance = echarts.init(document.getElementById("chart"));
    this.loadCharts()
    this.loadChartsBind = this.loadCharts.bind(this)
    window.addEventListener('resize', this.loadChartsBind)
  },
  methods: {
    loadCharts() {
      this.echartInstance.clear()
      const option = {
        title: {
          // text: "Test Demo",
43
        },
潘际乾 committed
44 45 46 47 48
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
49
        },
潘际乾 committed
50 51
        legend: {
          bottom: "2%",
52
        },
潘际乾 committed
53 54 55 56 57
        grid: {
          left: "1%",
          right: "6%",
          top: "1%",
          containLabel: true,
58
        },
潘际乾 committed
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
        xAxis: {
          type: "value",
          boundaryGap: [0, 0.01],
        },
        yAxis: {
          type: "category",
          data: [
            "海康威视",
            "春晖指控",
            "苏奥传感",
            "东方财富",
            "隆基股份",
            "贵州茅台",
          ],
        },
        series: [
          {
            name: "业务量(万美元)",
            type: "bar",
            data: [18203, 23489, 29034, 104970, 131744, 230230],
          },
          {
            name: "融资量(万美元)",
            type: "bar",
            data: [19325, 23438, 31000, 121594, 134141, 381807],
          },
          {
            name: "费用收益(千美元)",
            type: "bar",
            data: [49325, 53438, 11000, 221594, 43241, 455807],
          },
        ],
      };
      this.echartInstance.setOption(option);
    },
94
  },
潘际乾 committed
95 96 97
  destroyed() {
    window.removeEventListener('resize', this.loadChartsBind)
  }
98 99 100 101
};
</script>

<style scoped>
潘际乾 committed
102 103 104 105 106
#customerAnalyse .cell-content {
  display: flex;
  flex-direction: column;
  padding: 0 5px;
}
潘际乾 committed
107
#customerAnalyse .cell-content .chart-operate {
108 109 110
  margin-left: 20px;
  height: 20px;
}
潘际乾 committed
111
#customerAnalyse .cell-content .chart-operate i {
112 113
  cursor: pointer;
}
潘际乾 committed
114 115 116 117 118 119 120 121 122 123
#customerAnalyse .cell-content #chartWrapper {
  /* width: 98%; */
  /* height: calc(100% - 50px); */
  /* height: 200px; */
  /* margin: 0 auto; */
  flex: 1;
}
#customerAnalyse .cell-content #chartWrapper #chart {
  width: 100%;
  height: 100%;
124 125
}
</style>