修改bug
This commit is contained in:
		@@ -8,33 +8,25 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <chart-container class="line-chart-base">
 | 
					  <chart-container class="line-chart-base">
 | 
				
			||||||
    <div class="legend">
 | 
					    <div class="legend">
 | 
				
			||||||
      <span
 | 
					      <span v-for="item in legend" :key="item.label" class="legend-item"
 | 
				
			||||||
        v-for="item in legend"
 | 
					        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
 | 
				
			||||||
        :key="item.label"
 | 
					 | 
				
			||||||
        class="legend-item"
 | 
					 | 
				
			||||||
        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
 | 
					 | 
				
			||||||
        >{{ item.label }}</span
 | 
					 | 
				
			||||||
      >
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div
 | 
					    <div ref="chart" :style="{ height: '100%',width: width}"></div>
 | 
				
			||||||
      ref="chart"
 | 
					 | 
				
			||||||
      style="max-width: 50vw"
 | 
					 | 
				
			||||||
      :style="{ height: vHeight + 'vh' }"
 | 
					 | 
				
			||||||
    ></div>
 | 
					 | 
				
			||||||
  </chart-container>
 | 
					  </chart-container>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import screenfull from "screenfull";
 | 
					import screenfull from "screenfull";
 | 
				
			||||||
 | 
					import { debounce } from "@/utils/debounce";
 | 
				
			||||||
import ChartContainer from "./ChartContainer.vue";
 | 
					import ChartContainer from "./ChartContainer.vue";
 | 
				
			||||||
import chartMixin from "@/mixins/chart.js";
 | 
					// import chartMixin from "@/mixins/chart.js";
 | 
				
			||||||
import * as echarts from "echarts";
 | 
					import * as echarts from "echarts";
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "LineChartBase",
 | 
					  name: "LineChartBase",
 | 
				
			||||||
  components: {
 | 
					  components: {
 | 
				
			||||||
    ChartContainer,
 | 
					    ChartContainer,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mixins: [chartMixin],
 | 
					  // mixins: [chartMixin],
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    vHeight: {
 | 
					    vHeight: {
 | 
				
			||||||
      type: Number,
 | 
					      type: Number,
 | 
				
			||||||
@@ -59,6 +51,7 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
 | 
					      width:'100%',
 | 
				
			||||||
      isFullscreen: false,
 | 
					      isFullscreen: false,
 | 
				
			||||||
      actualOptions: null,
 | 
					      actualOptions: null,
 | 
				
			||||||
      options: {
 | 
					      options: {
 | 
				
			||||||
@@ -84,11 +77,11 @@ export default {
 | 
				
			|||||||
        // legend: {
 | 
					        // legend: {
 | 
				
			||||||
        //   data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
 | 
					        //   data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
 | 
				
			||||||
        // },
 | 
					        // },
 | 
				
			||||||
        toolbox: {
 | 
					        // toolbox: {
 | 
				
			||||||
          feature: {
 | 
					        //   feature: {
 | 
				
			||||||
            saveAsImage: {}
 | 
					        //     saveAsImage: {}
 | 
				
			||||||
          }
 | 
					        //   }
 | 
				
			||||||
        },
 | 
					        // },
 | 
				
			||||||
        grid: {
 | 
					        grid: {
 | 
				
			||||||
          left: '3%',
 | 
					          left: '3%',
 | 
				
			||||||
          right: '4%',
 | 
					          right: '4%',
 | 
				
			||||||
@@ -366,7 +359,21 @@ export default {
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    isOpen() {
 | 
				
			||||||
 | 
					      return this.$store.getters.sidebar.opened
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
 | 
					    isOpen(val) {
 | 
				
			||||||
 | 
					      if (val === true) {
 | 
				
			||||||
 | 
					        this.width = '100%-128px'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.watch = 100 + '%'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
					    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
				
			||||||
    isFullscreen(val) {
 | 
					    isFullscreen(val) {
 | 
				
			||||||
      this.actualOptions.series.map((item) => {
 | 
					      this.actualOptions.series.map((item) => {
 | 
				
			||||||
@@ -375,11 +382,11 @@ export default {
 | 
				
			|||||||
      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.initOptions(this.actualOptions);
 | 
					      this.initChart(this.actualOptions);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    series(val) {
 | 
					    series(val) {
 | 
				
			||||||
      if (!val) {
 | 
					      if (!val) {
 | 
				
			||||||
        this.initOptions(this.options);
 | 
					        this.initChart(this.options);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const actualOptions = JSON.parse(JSON.stringify(this.options));
 | 
					      const actualOptions = JSON.parse(JSON.stringify(this.options));
 | 
				
			||||||
@@ -388,19 +395,42 @@ export default {
 | 
				
			|||||||
      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
					      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
				
			||||||
      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
					      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
				
			||||||
      this.actualOptions = actualOptions;
 | 
					      this.actualOptions = actualOptions;
 | 
				
			||||||
      this.initOptions(actualOptions);
 | 
					      this.initChart(actualOptions);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mounted() {
 | 
					 | 
				
			||||||
    this.actualOptions = this.options;
 | 
					 | 
				
			||||||
    this.initOptions(this.options);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (screenfull.isEnabled) {
 | 
					  mounted() {
 | 
				
			||||||
      screenfull.on("change", () => {
 | 
					    // if (screenfull.isEnabled) {
 | 
				
			||||||
        this.isFullscreen = screenfull.isFullscreen;
 | 
					    //   screenfull.on("change", () => {
 | 
				
			||||||
      });
 | 
					    //     this.isFullscreen = screenfull.isFullscreen;
 | 
				
			||||||
 | 
					    //   });
 | 
				
			||||||
 | 
					    // }
 | 
				
			||||||
 | 
					    this.actualOptions = this.options
 | 
				
			||||||
 | 
					    this.canvasReset();
 | 
				
			||||||
 | 
					    window.addEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  beforeDestroy() {
 | 
				
			||||||
 | 
					    if (this.chart) {
 | 
				
			||||||
 | 
					      this.chart.dispose();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  destroyed() {
 | 
				
			||||||
 | 
					    window.removeEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    canvasReset() {
 | 
				
			||||||
 | 
					      debounce(() => {
 | 
				
			||||||
 | 
					        this.initChart();
 | 
				
			||||||
 | 
					      }, 500)();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    initChart() {
 | 
				
			||||||
 | 
					      if (this.chart) {
 | 
				
			||||||
 | 
					        this.chart.dispose();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.chart = echarts.init(this.$refs.chart);
 | 
				
			||||||
 | 
					      this.chart.setOption(this.actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,3 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
<!--
 | 
					<!--
 | 
				
			||||||
    filename: LineChartBase.vue
 | 
					    filename: LineChartBase.vue
 | 
				
			||||||
    author: liubin
 | 
					    author: liubin
 | 
				
			||||||
@@ -9,33 +8,25 @@
 | 
				
			|||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <chart-container class="line-chart-base">
 | 
					  <chart-container class="line-chart-base">
 | 
				
			||||||
    <div class="legend">
 | 
					    <div class="legend">
 | 
				
			||||||
      <span
 | 
					      <span v-for="item in legend" :key="item.label" class="legend-item"
 | 
				
			||||||
        v-for="item in legend"
 | 
					        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
 | 
				
			||||||
        :key="item.label"
 | 
					 | 
				
			||||||
        class="legend-item"
 | 
					 | 
				
			||||||
        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
 | 
					 | 
				
			||||||
        >{{ item.label }}</span
 | 
					 | 
				
			||||||
      >
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div
 | 
					    <div ref="chart" :style="{ height: '100%',width: width}"></div>
 | 
				
			||||||
      ref="chart"
 | 
					 | 
				
			||||||
      style="max-width: 50vw"
 | 
					 | 
				
			||||||
      :style="{ height: vHeight + 'vh' }"
 | 
					 | 
				
			||||||
    ></div>
 | 
					 | 
				
			||||||
  </chart-container>
 | 
					  </chart-container>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import screenfull from "screenfull";
 | 
					import screenfull from "screenfull";
 | 
				
			||||||
 | 
					import { debounce } from "@/utils/debounce";
 | 
				
			||||||
import ChartContainer from "./ChartContainer.vue";
 | 
					import ChartContainer from "./ChartContainer.vue";
 | 
				
			||||||
import chartMixin from "@/mixins/chart.js";
 | 
					// import chartMixin from "@/mixins/chart.js";
 | 
				
			||||||
import * as echarts from "echarts";
 | 
					import * as echarts from "echarts";
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "LineChartBase",
 | 
					  name: "LineChartBase",
 | 
				
			||||||
  components: {
 | 
					  components: {
 | 
				
			||||||
    ChartContainer,
 | 
					    ChartContainer,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mixins: [chartMixin],
 | 
					  // mixins: [chartMixin],
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    vHeight: {
 | 
					    vHeight: {
 | 
				
			||||||
      type: Number,
 | 
					      type: Number,
 | 
				
			||||||
@@ -60,6 +51,7 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
 | 
					      width: '100%',
 | 
				
			||||||
      isFullscreen: false,
 | 
					      isFullscreen: false,
 | 
				
			||||||
      actualOptions: null,
 | 
					      actualOptions: null,
 | 
				
			||||||
      options: {
 | 
					      options: {
 | 
				
			||||||
@@ -85,11 +77,11 @@ export default {
 | 
				
			|||||||
        // legend: {
 | 
					        // legend: {
 | 
				
			||||||
        //   data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
 | 
					        //   data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
 | 
				
			||||||
        // },
 | 
					        // },
 | 
				
			||||||
        toolbox: {
 | 
					        // toolbox: {
 | 
				
			||||||
          feature: {
 | 
					        //   feature: {
 | 
				
			||||||
            saveAsImage: {}
 | 
					        //     saveAsImage: {}
 | 
				
			||||||
          }
 | 
					        //   }
 | 
				
			||||||
        },
 | 
					        // },
 | 
				
			||||||
        grid: {
 | 
					        grid: {
 | 
				
			||||||
          left: '3%',
 | 
					          left: '3%',
 | 
				
			||||||
          right: '4%',
 | 
					          right: '4%',
 | 
				
			||||||
@@ -368,6 +360,15 @@ export default {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
 | 
					    isOpen(val) {
 | 
				
			||||||
 | 
					      if (val === true) {
 | 
				
			||||||
 | 
					        this.width = '100%-128px'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.watch = 100 + '%'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
					    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
				
			||||||
    isFullscreen(val) {
 | 
					    isFullscreen(val) {
 | 
				
			||||||
      this.actualOptions.series.map((item) => {
 | 
					      this.actualOptions.series.map((item) => {
 | 
				
			||||||
@@ -376,11 +377,11 @@ export default {
 | 
				
			|||||||
      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.initOptions(this.actualOptions);
 | 
					      this.initChart(this.actualOptions);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    series(val) {
 | 
					    series(val) {
 | 
				
			||||||
      if (!val) {
 | 
					      if (!val) {
 | 
				
			||||||
        this.initOptions(this.options);
 | 
					        this.initChart(this.options);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      const actualOptions = JSON.parse(JSON.stringify(this.options));
 | 
					      const actualOptions = JSON.parse(JSON.stringify(this.options));
 | 
				
			||||||
@@ -389,19 +390,46 @@ export default {
 | 
				
			|||||||
      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
					      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
				
			||||||
      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
					      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
				
			||||||
      this.actualOptions = actualOptions;
 | 
					      this.actualOptions = actualOptions;
 | 
				
			||||||
      this.initOptions(actualOptions);
 | 
					      this.initChart(actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    isOpen() {
 | 
				
			||||||
 | 
					      return this.$store.getters.sidebar.opened
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mounted() {
 | 
					  mounted() {
 | 
				
			||||||
    this.actualOptions = this.options;
 | 
					    // if (screenfull.isEnabled) {
 | 
				
			||||||
    this.initOptions(this.options);
 | 
					    //   screenfull.on("change", () => {
 | 
				
			||||||
 | 
					    //     this.isFullscreen = screenfull.isFullscreen;
 | 
				
			||||||
    if (screenfull.isEnabled) {
 | 
					    //   });
 | 
				
			||||||
      screenfull.on("change", () => {
 | 
					    // }
 | 
				
			||||||
        this.isFullscreen = screenfull.isFullscreen;
 | 
					    this.actualOptions = this.options
 | 
				
			||||||
      });
 | 
					    this.canvasReset();
 | 
				
			||||||
 | 
					    window.addEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  beforeDestroy() {
 | 
				
			||||||
 | 
					    if (this.chart) {
 | 
				
			||||||
 | 
					      this.chart.dispose();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  destroyed() {
 | 
				
			||||||
 | 
					    window.removeEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    canvasReset() {
 | 
				
			||||||
 | 
					      debounce(() => {
 | 
				
			||||||
 | 
					        this.initChart();
 | 
				
			||||||
 | 
					      }, 500)();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    initChart() {
 | 
				
			||||||
 | 
					      if (this.chart) {
 | 
				
			||||||
 | 
					        this.chart.dispose();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.chart = echarts.init(this.$refs.chart);
 | 
				
			||||||
 | 
					      this.chart.setOption(this.actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										297
									
								
								src/views/copilot/components/gasBarChartBase.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										297
									
								
								src/views/copilot/components/gasBarChartBase.vue
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,297 @@
 | 
				
			|||||||
 | 
					<!--
 | 
				
			||||||
 | 
					 * @Author: zhp
 | 
				
			||||||
 | 
					 * @Date: 2024-05-13 14:08:51
 | 
				
			||||||
 | 
					 * @LastEditTime: 2024-05-13 16:19:44
 | 
				
			||||||
 | 
					 * @LastEditors: zhp
 | 
				
			||||||
 | 
					 * @Description:
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<template>
 | 
				
			||||||
 | 
					  <chart-container class="bar-chart-base">
 | 
				
			||||||
 | 
					    <div class="legend">
 | 
				
			||||||
 | 
					      <span v-for="item in legend" :key="item.label" class="legend-item"
 | 
				
			||||||
 | 
					        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					    <div id="chart" ref="chart" :style="{ height: '100%',width: width}"></div>
 | 
				
			||||||
 | 
					  </chart-container>
 | 
				
			||||||
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					import screenfull from "screenfull";
 | 
				
			||||||
 | 
					import ChartContainer from "./ChartContainer.vue";
 | 
				
			||||||
 | 
					// import chartMixin from "@/mixins/chart.js";
 | 
				
			||||||
 | 
					import { debounce } from "@/utils/debounce";
 | 
				
			||||||
 | 
					import * as echarts from "echarts";
 | 
				
			||||||
 | 
					export default {
 | 
				
			||||||
 | 
					  name: "BarChartBase",
 | 
				
			||||||
 | 
					  components: {
 | 
				
			||||||
 | 
					    ChartContainer,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  // mixins: [chartMixin],
 | 
				
			||||||
 | 
					  props: {
 | 
				
			||||||
 | 
					    vHeight: {
 | 
				
			||||||
 | 
					      type: Number,
 | 
				
			||||||
 | 
					      default: 38,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    legend: {
 | 
				
			||||||
 | 
					      type: Array,
 | 
				
			||||||
 | 
					      required: false,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    xAxis: {
 | 
				
			||||||
 | 
					      type: Array,
 | 
				
			||||||
 | 
					      required: true,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    series: {
 | 
				
			||||||
 | 
					      type: Array,
 | 
				
			||||||
 | 
					      required: true,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    in: {
 | 
				
			||||||
 | 
					      type: String,
 | 
				
			||||||
 | 
					      default: "",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  data() {
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					      isFullscreen: false,
 | 
				
			||||||
 | 
					      actualOptions: null,
 | 
				
			||||||
 | 
					      options: {
 | 
				
			||||||
 | 
					        grid: {
 | 
				
			||||||
 | 
					          left: "5%",
 | 
				
			||||||
 | 
					          right: "1%",
 | 
				
			||||||
 | 
					          bottom: "3%",
 | 
				
			||||||
 | 
					          top: "15%",
 | 
				
			||||||
 | 
					          containLabel: true,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        tooltip: {},
 | 
				
			||||||
 | 
					        xAxis: {
 | 
				
			||||||
 | 
					          axisTick: {
 | 
				
			||||||
 | 
					            show: false,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          axisLine: {
 | 
				
			||||||
 | 
					            lineStyle: {
 | 
				
			||||||
 | 
					              color: "#4561AE",
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          axisLabel: {
 | 
				
			||||||
 | 
					            color: "#fff",
 | 
				
			||||||
 | 
					            fontSize: 12,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          data: this.xAxis,
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        yAxis: {
 | 
				
			||||||
 | 
					          name: "单位/片",
 | 
				
			||||||
 | 
					          nameTextStyle: {
 | 
				
			||||||
 | 
					            color: "#fff",
 | 
				
			||||||
 | 
					            fontSize: 12,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          axisTick: {
 | 
				
			||||||
 | 
					            show: false,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          axisLabel: {
 | 
				
			||||||
 | 
					            color: "#fff",
 | 
				
			||||||
 | 
					            fontSize: 12,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          axisLine: {
 | 
				
			||||||
 | 
					            show: true,
 | 
				
			||||||
 | 
					            lineStyle: {
 | 
				
			||||||
 | 
					              color: "#4561AE",
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          splitLine: {
 | 
				
			||||||
 | 
					            lineStyle: {
 | 
				
			||||||
 | 
					              color: "#4561AE",
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        series: [
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            name: "", // this.series[0].name,
 | 
				
			||||||
 | 
					            type: "bar",
 | 
				
			||||||
 | 
					            barWidth: 12,
 | 
				
			||||||
 | 
					            itemStyle: {
 | 
				
			||||||
 | 
					              borderRadius: [10, 10, 0, 0],
 | 
				
			||||||
 | 
					              color: {
 | 
				
			||||||
 | 
					                type: "linear",
 | 
				
			||||||
 | 
					                x: 0,
 | 
				
			||||||
 | 
					                y: 0,
 | 
				
			||||||
 | 
					                x2: 0,
 | 
				
			||||||
 | 
					                y2: 1,
 | 
				
			||||||
 | 
					                colorStops: [
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 0,
 | 
				
			||||||
 | 
					                    color: "#12f7f1", // 0% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 0.35,
 | 
				
			||||||
 | 
					                    color: "#12f7f177", // 100% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 0.75,
 | 
				
			||||||
 | 
					                    color: "#12f7f133", // 100% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 1,
 | 
				
			||||||
 | 
					                    color: "transparent", // 100% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
 | 
					                global: false, // 缺省为 false
 | 
				
			||||||
 | 
					              },
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            data: [], // this.series[0].data,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            name: "", // this.series[1].name,
 | 
				
			||||||
 | 
					            type: "bar",
 | 
				
			||||||
 | 
					            barWidth: 12,
 | 
				
			||||||
 | 
					            // tooltip: {
 | 
				
			||||||
 | 
					            //   valueFormatter: function (value) {
 | 
				
			||||||
 | 
					            //     return value + " ml";
 | 
				
			||||||
 | 
					            //   },
 | 
				
			||||||
 | 
					            // },
 | 
				
			||||||
 | 
					            itemStyle: {
 | 
				
			||||||
 | 
					              borderRadius: [10, 10, 0, 0],
 | 
				
			||||||
 | 
					              color: {
 | 
				
			||||||
 | 
					                type: "linear",
 | 
				
			||||||
 | 
					                x: 0,
 | 
				
			||||||
 | 
					                y: 0,
 | 
				
			||||||
 | 
					                x2: 0,
 | 
				
			||||||
 | 
					                y2: 1,
 | 
				
			||||||
 | 
					                colorStops: [
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 0,
 | 
				
			||||||
 | 
					                    color: "#57abf8", // 0% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                  {
 | 
				
			||||||
 | 
					                    offset: 1,
 | 
				
			||||||
 | 
					                    color: "#364BFE66", // 100% 处的颜色
 | 
				
			||||||
 | 
					                  },
 | 
				
			||||||
 | 
					                ],
 | 
				
			||||||
 | 
					                global: false, // 缺省为 false
 | 
				
			||||||
 | 
					              },
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            data: [], // this.series[1].data,
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    isOpen() {
 | 
				
			||||||
 | 
					      return this.$store.getters.sidebar.opened
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  watch: {
 | 
				
			||||||
 | 
					    isOpen(val) {
 | 
				
			||||||
 | 
					      if (val === true) {
 | 
				
			||||||
 | 
					        this.width = '100%-128px'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.watch = 100 + '%'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
				
			||||||
 | 
					    isFullscreen(val) {
 | 
				
			||||||
 | 
					      this.actualOptions.series.map((item) => {
 | 
				
			||||||
 | 
					        item.barWidth = val ? 18 : 12;
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
 | 
					      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
 | 
					      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
				
			||||||
 | 
					      this.initOptions(this.actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    series(val) {
 | 
				
			||||||
 | 
					      if (!val) {
 | 
				
			||||||
 | 
					        this.initOptions(this.options);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      const actualOptions = JSON.parse(JSON.stringify(this.options));
 | 
				
			||||||
 | 
					      console.log('actualOptions', this.options)
 | 
				
			||||||
 | 
					      actualOptions.series[0].data = val[0].data;
 | 
				
			||||||
 | 
					      actualOptions.series[0].name = val[0].name;
 | 
				
			||||||
 | 
					      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
				
			||||||
 | 
					      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
				
			||||||
 | 
					      this.actualOptions = actualOptions;
 | 
				
			||||||
 | 
					      this.initChart(actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  mounted() {
 | 
				
			||||||
 | 
					    // if (screenfull.isEnabled) {
 | 
				
			||||||
 | 
					    //   screenfull.on("change", () => {
 | 
				
			||||||
 | 
					    //     this.isFullscreen = screenfull.isFullscreen;
 | 
				
			||||||
 | 
					    //   });
 | 
				
			||||||
 | 
					    // }
 | 
				
			||||||
 | 
					    this.actualOptions = this.options
 | 
				
			||||||
 | 
					    this.canvasReset();
 | 
				
			||||||
 | 
					    window.addEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  beforeDestroy() {
 | 
				
			||||||
 | 
					    if (this.chart) {
 | 
				
			||||||
 | 
					      this.chart.dispose();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  destroyed() {
 | 
				
			||||||
 | 
					    window.removeEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    canvasReset() {
 | 
				
			||||||
 | 
					      debounce(() => {
 | 
				
			||||||
 | 
					        this.initChart();
 | 
				
			||||||
 | 
					      }, 500)();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    initChart() {
 | 
				
			||||||
 | 
					      if (this.chart) {
 | 
				
			||||||
 | 
					        this.chart.dispose();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.chart = echarts.init(this.$refs.chart);
 | 
				
			||||||
 | 
					      this.chart.setOption(this.actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  // mounted() {
 | 
				
			||||||
 | 
					  //   this.actualOptions = this.options;
 | 
				
			||||||
 | 
					  //   this.initOptions(this.options);
 | 
				
			||||||
 | 
					  //   window.addEventListener("resize", this.initOptions(this.actualOptions))
 | 
				
			||||||
 | 
					  //   if (screenfull.isEnabled) {
 | 
				
			||||||
 | 
					  //     screenfull.on("change", () => {
 | 
				
			||||||
 | 
					  //       this.isFullscreen = screenfull.isFullscreen;
 | 
				
			||||||
 | 
					  //     });
 | 
				
			||||||
 | 
					  //   }
 | 
				
			||||||
 | 
					  // },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<style scoped lang="scss">
 | 
				
			||||||
 | 
					.bar-chart-base {
 | 
				
			||||||
 | 
					  // position: relative;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .legend {
 | 
				
			||||||
 | 
					    position: absolute;
 | 
				
			||||||
 | 
					    top: 5.2vh;
 | 
				
			||||||
 | 
					    right: 1vw;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .legend-item {
 | 
				
			||||||
 | 
					    position: relative;
 | 
				
			||||||
 | 
					    // font-size: 12px;
 | 
				
			||||||
 | 
					    margin-right: 0.67vw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    &::before {
 | 
				
			||||||
 | 
					      content: "";
 | 
				
			||||||
 | 
					      display: inline-block;
 | 
				
			||||||
 | 
					      width: 0.531vw;
 | 
				
			||||||
 | 
					      height: 0.531vw;
 | 
				
			||||||
 | 
					      background-color: #ccc;
 | 
				
			||||||
 | 
					      border-radius: 2px;
 | 
				
			||||||
 | 
					      margin-right: 0.22vw;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .legend-item:nth-child(1):before {
 | 
				
			||||||
 | 
					    background-color: #12f7f1;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  .legend-item:nth-child(2):before {
 | 
				
			||||||
 | 
					    background-color: #58adfa;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
@@ -1,40 +1,32 @@
 | 
				
			|||||||
<!--
 | 
					<!--
 | 
				
			||||||
 * @Author: zhp
 | 
					 * @Author: zhp
 | 
				
			||||||
 * @Date: 2024-05-07 13:22:43
 | 
					 * @Date: 2024-05-07 13:22:43
 | 
				
			||||||
 * @LastEditTime: 2024-05-09 16:22:24
 | 
					 * @LastEditTime: 2024-05-13 16:19:17
 | 
				
			||||||
 * @LastEditors: zhp
 | 
					 * @LastEditors: zhp
 | 
				
			||||||
 * @Description:
 | 
					 * @Description:
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <chart-container class="bar-chart-base">
 | 
					  <chart-container class="bar-chart-base">
 | 
				
			||||||
    <div class="legend">
 | 
					    <div class="legend">
 | 
				
			||||||
      <span
 | 
					      <span v-for="item in legend" :key="item.label" class="legend-item"
 | 
				
			||||||
        v-for="item in legend"
 | 
					        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
 | 
				
			||||||
        :key="item.label"
 | 
					 | 
				
			||||||
        class="legend-item"
 | 
					 | 
				
			||||||
        :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
 | 
					 | 
				
			||||||
        >{{ item.label }}</span
 | 
					 | 
				
			||||||
      >
 | 
					 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <div
 | 
					    <div ref="chart" :style="{ height: '100%',width: width}"></div>
 | 
				
			||||||
      ref="chart"
 | 
					 | 
				
			||||||
      style="max-width: 40vw"
 | 
					 | 
				
			||||||
      :style="{ height: vHeight + 'vh' }"
 | 
					 | 
				
			||||||
    ></div>
 | 
					 | 
				
			||||||
  </chart-container>
 | 
					  </chart-container>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import screenfull from "screenfull";
 | 
					import screenfull from "screenfull";
 | 
				
			||||||
import ChartContainer from "../../../../components/ChartContainer.vue";
 | 
					import ChartContainer from "../../../../components/ChartContainer.vue";
 | 
				
			||||||
import chartMixin from "@/mixins/chart.js";
 | 
					// import chartMixin from "@/mixins/chart.js";
 | 
				
			||||||
 | 
					import { debounce } from "@/utils/debounce";
 | 
				
			||||||
 | 
					import * as echarts from "echarts";
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "BarChartBase",
 | 
					  name: "BarChartBase",
 | 
				
			||||||
  components: {
 | 
					  components: {
 | 
				
			||||||
    ChartContainer,
 | 
					    ChartContainer,
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mixins: [chartMixin],
 | 
					  // mixins: [chartMixin],
 | 
				
			||||||
  props: {
 | 
					  props: {
 | 
				
			||||||
    vHeight: {
 | 
					    vHeight: {
 | 
				
			||||||
      type: Number,
 | 
					      type: Number,
 | 
				
			||||||
@@ -64,7 +56,7 @@ export default {
 | 
				
			|||||||
      options: {
 | 
					      options: {
 | 
				
			||||||
        grid: {
 | 
					        grid: {
 | 
				
			||||||
          left: "5%",
 | 
					          left: "5%",
 | 
				
			||||||
          right: "4%",
 | 
					          right: "0%",
 | 
				
			||||||
          bottom: "3%",
 | 
					          bottom: "3%",
 | 
				
			||||||
          top: "15%",
 | 
					          top: "15%",
 | 
				
			||||||
          containLabel: true,
 | 
					          containLabel: true,
 | 
				
			||||||
@@ -182,7 +174,21 @@ export default {
 | 
				
			|||||||
      },
 | 
					      },
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  computed: {
 | 
				
			||||||
 | 
					    isOpen() {
 | 
				
			||||||
 | 
					      return this.$store.getters.sidebar.opened
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
 | 
					    isOpen(val) {
 | 
				
			||||||
 | 
					      if (val === true) {
 | 
				
			||||||
 | 
					        this.width = '100%-128px'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        this.watch = 100 + '%'
 | 
				
			||||||
 | 
					        this.canvasReset()
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
					    /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
 | 
				
			||||||
    isFullscreen(val) {
 | 
					    isFullscreen(val) {
 | 
				
			||||||
      this.actualOptions.series.map((item) => {
 | 
					      this.actualOptions.series.map((item) => {
 | 
				
			||||||
@@ -191,11 +197,11 @@ export default {
 | 
				
			|||||||
      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
					      this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
 | 
				
			||||||
      this.initOptions(this.actualOptions);
 | 
					      this.initChart(this.actualOptions);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    series(val) {
 | 
					    series(val) {
 | 
				
			||||||
      if (!val) {
 | 
					      if (!val) {
 | 
				
			||||||
        this.initOptions(this.options);
 | 
					        this.initChart(this.options);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      console.log(val)
 | 
					      console.log(val)
 | 
				
			||||||
@@ -205,19 +211,41 @@ export default {
 | 
				
			|||||||
      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
					      actualOptions.series[1].data = val?.[1]?.data || [];
 | 
				
			||||||
      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
					      actualOptions.series[1].name = val?.[1]?.name || "";
 | 
				
			||||||
      this.actualOptions = actualOptions;
 | 
					      this.actualOptions = actualOptions;
 | 
				
			||||||
      this.initOptions(actualOptions);
 | 
					      this.initChart(actualOptions);
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mounted() {
 | 
					  mounted() {
 | 
				
			||||||
    this.actualOptions = this.options;
 | 
					    // if (screenfull.isEnabled) {
 | 
				
			||||||
    this.initOptions(this.options);
 | 
					    //   screenfull.on("change", () => {
 | 
				
			||||||
 | 
					    //     this.isFullscreen = screenfull.isFullscreen;
 | 
				
			||||||
    if (screenfull.isEnabled) {
 | 
					    //   });
 | 
				
			||||||
      screenfull.on("change", () => {
 | 
					    // }
 | 
				
			||||||
        this.isFullscreen = screenfull.isFullscreen;
 | 
					    this.actualOptions = this.options
 | 
				
			||||||
      });
 | 
					    this.canvasReset();
 | 
				
			||||||
 | 
					    window.addEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  beforeDestroy() {
 | 
				
			||||||
 | 
					    if (this.chart) {
 | 
				
			||||||
 | 
					      this.chart.dispose();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					  destroyed() {
 | 
				
			||||||
 | 
					    window.removeEventListener("resize", this.canvasReset);
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  methods: {
 | 
				
			||||||
 | 
					    canvasReset() {
 | 
				
			||||||
 | 
					      debounce(() => {
 | 
				
			||||||
 | 
					        this.initChart();
 | 
				
			||||||
 | 
					      }, 500)();
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    initChart() {
 | 
				
			||||||
 | 
					      if (this.chart) {
 | 
				
			||||||
 | 
					        this.chart.dispose();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.chart = echarts.init(this.$refs.chart);
 | 
				
			||||||
 | 
					      this.chart.setOption(this.actualOptions);
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@
 | 
				
			|||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
import BarChartBase from "@/views/copilot/components/BarChartBase.vue";
 | 
					import BarChartBase from "@/views/copilot/components/gasBarChartBase.vue";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default {
 | 
					export default {
 | 
				
			||||||
  name: "NatGasCost",
 | 
					  name: "NatGasCost",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
<!--
 | 
					<!--
 | 
				
			||||||
 * @Author: zhp
 | 
					 * @Author: zhp
 | 
				
			||||||
 * @Date: 2024-05-07 10:25:10
 | 
					 * @Date: 2024-05-07 10:25:10
 | 
				
			||||||
 * @LastEditTime: 2024-05-09 08:41:11
 | 
					 * @LastEditTime: 2024-05-13 15:48:10
 | 
				
			||||||
 * @LastEditors: zhp
 | 
					 * @LastEditors: zhp
 | 
				
			||||||
 * @Description:
 | 
					 * @Description:
 | 
				
			||||||
-->
 | 
					-->
 | 
				
			||||||
@@ -56,8 +56,11 @@ export default {
 | 
				
			|||||||
      immediate: true,
 | 
					      immediate: true,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    fetchData(period = "日") {
 | 
					    fetchData(period = "日") {
 | 
				
			||||||
 | 
					      // console.log(this.width);
 | 
				
			||||||
 | 
					      // console.log('sidebar', this.$store.getters.sidebar);
 | 
				
			||||||
      console.log(`效率驾驶舱,获取${period}数据`);
 | 
					      console.log(`效率驾驶舱,获取${period}数据`);
 | 
				
			||||||
      this.$store.dispatch("copilot/initCopilot", {
 | 
					      this.$store.dispatch("copilot/initCopilot", {
 | 
				
			||||||
        period,
 | 
					        period,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,11 +40,14 @@ export default {
 | 
				
			|||||||
      };
 | 
					      };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  mounted () {
 | 
					  mounted() {
 | 
				
			||||||
    ;this.getTimes()
 | 
					    this.getTimes()
 | 
				
			||||||
    this.getWeather()
 | 
					    this.weatherInterval = setInterval(() => {
 | 
				
			||||||
 | 
					      this,this.getWeather()
 | 
				
			||||||
 | 
					    }, 1000)
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  destroyed() {
 | 
					  destroyed() {
 | 
				
			||||||
 | 
					    // console.log(1111)
 | 
				
			||||||
    clearInterval(this.weatherInterval)
 | 
					    clearInterval(this.weatherInterval)
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
@@ -87,23 +90,21 @@ export default {
 | 
				
			|||||||
        '.' +
 | 
					        '.' +
 | 
				
			||||||
        day
 | 
					        day
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
   async getWeather() {
 | 
					    getWeather() {
 | 
				
			||||||
     this.weatherInterval = setInterval(() => {
 | 
					      fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, {
 | 
				
			||||||
       fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, {
 | 
					        method: 'get',
 | 
				
			||||||
          method: 'get',
 | 
					        extensions: 'base',
 | 
				
			||||||
         extensions: 'base',
 | 
					 | 
				
			||||||
        //  output:'JSON'
 | 
					        //  output:'JSON'
 | 
				
			||||||
       }).then((response) => {
 | 
					      }).then((response) => {
 | 
				
			||||||
         // 注意此处
 | 
					        // 注意此处
 | 
				
			||||||
         response.json().then((data) => {
 | 
					        response.json().then((data) => {
 | 
				
			||||||
           console.log(data)
 | 
					          console.log(data)
 | 
				
			||||||
           this.weather = data.lives[0].weather + '   '+ data.lives[0].temperature + '℃'
 | 
					          this.weather = data.lives[0].weather + '   ' + data.lives[0].temperature + '℃'
 | 
				
			||||||
         }).catch((err) => {
 | 
					        }).catch((err) => {
 | 
				
			||||||
          this.weather = '晴  25℃'
 | 
					          this.weather = '晴  25℃'
 | 
				
			||||||
           console.log(err);
 | 
					          console.log(err);
 | 
				
			||||||
         })
 | 
					        })
 | 
				
			||||||
       })
 | 
					      })
 | 
				
			||||||
      }, 1000)
 | 
					 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    toggleFullscreen() {
 | 
					    toggleFullscreen() {
 | 
				
			||||||
      screenfull.toggle();
 | 
					      screenfull.toggle();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user