管道基础大数据平台系统开发-【前端】-新系統界面
suerprisePlus
2024-06-05 7d6ab2c59d244de2acb0a3ef920f7a2b7728efbe
src/components/echart45.vue
@@ -10,106 +10,110 @@
  components: {},
  data() {
    //这里存放数据
    return {};
    return { myChart:null };
  },
  mounted() {
    this.lineChart();
    this.$bus.$on('resizeEchart', (res) => {
      this.myChart.resize();
    });
  },
  //方法集合
  methods: {
    lineChart() {
      let option = {
        title: {
          text: "资金使用和预算对比",
          text: '资金使用和预算对比',
          top:15,
          textStyle: {
            color: "#fff",
            color: '#fff',
          },
        },
        tooltip: {
          trigger: "axis",
          trigger: 'axis',
          axisPointer: {
            type: "shadow",
            type: 'shadow',
          },
        },
        legend: {
          data: ["剩余金额", "已使用金额", "预算金额"],
          data: ['剩余金额', '已使用金额', '预算金额'],
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
        },
        xAxis: [
          {
            type: "value",
            type: 'value',
            axisLabel: {
              show: true,
              textStyle: {
                color: "#fff",
                color: '#fff',
              },
            },
          },
        ],
        yAxis: [
          {
            type: "category",
            type: 'category',
            axisTick: {
              show: false,
            },
            data: ["A2", "A3", "A4", "A5", "A6", "A7"],
            data: ['A2', 'A3', 'A4', 'A5', 'A6', 'A7'],
            axisLabel: {
              show: true,
              textStyle: {
                color: "#fff",
                color: '#fff',
              },
            },
          },
        ],
        series: [
          {
            name: "剩余",
            type: "bar",
            name: '剩余',
            type: 'bar',
            label: {
              show: true,
              position: "inside",
              position: 'inside',
            },
            emphasis: {
              focus: "series",
              focus: 'series',
            },
            data: [1200, 1440, 240, 350, 300, 630],
          },
          {
            name: "预算金额(万元)",
            type: "bar",
            stack: "Total",
            name: '预算金额(万元)',
            type: 'bar',
            stack: 'Total',
            label: {
              show: true,
            },
            emphasis: {
              focus: "series",
              focus: 'series',
            },
            data: [2000, 1800, 800, 1000, 600, 700],
          },
          {
            name: "已使用金额(万元)",
            type: "bar",
            stack: "Total",
            name: '已使用金额(万元)',
            type: 'bar',
            stack: 'Total',
            label: {
              show: true,
              position: "left",
              position: 'left',
            },
            emphasis: {
              focus: "series",
              focus: 'series',
            },
            data: [-800, -360, -560, -650, -300, -70],
          },
        ],
      };
      let myChart = this.$echarts.init(document.getElementById("echart45"));
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      this.myChart = this.$echarts.init(document.getElementById('echart45'));
      this.myChart.setOption(option);
      window.addEventListener('resize', function () {
        this.myChart.resize();
      });
    },
  },
@@ -120,10 +124,11 @@
//@import url(); 引入公共css类
.echart45_box {
  padding: 20px;
  // background: rgba(0, 0, 0, 0.6);
}
#echart45 {
  width: 100%;
  height: 100%;
}
#echart45 {
  width: calc(100% - 40px);
  height: calc(100% - 40px);
}
</style>