he wei
5 天以前 3c3576d5792bfabcef84979757ee344712e71cd3
src/components/echarts/bar1.vue
@@ -2,6 +2,7 @@
   import { onMounted, ref, watchEffect, nextTick, onBeforeUnmount } from "vue";
   import * as echarts from 'echarts';
  import baseChart from "./BaseChart.vue";
  import { toFixed } from '@/utils/toFixed.js';
  const chart = ref(null);
  const props = defineProps({
@@ -16,10 +17,12 @@
    unit: {
      type: String,
      default: ''
    }
    },
    barW: {
      type: [Number, String],
      default: 60,
    },
  });
  const barWidth = 60;
  function createLinearColor(color) {
    return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
@@ -39,13 +42,14 @@
  function getMax(data) {
    let max = Math.max.apply(null, data) * 1.2;
    return max || 1;
    return toFixed(max, 1) || 1;
  }
 function getOptions(xLabels, datas) {
    xLabels = xLabels || [];
    datas = datas || [];
    let barWidth = props.barW;
      const option = {
         // title: {
         //    text: props.title,
@@ -67,7 +71,7 @@
         grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            bottom: '8%',
        top: 30,
            containLabel: true
         },
@@ -188,8 +192,13 @@
    return chart_instance;
  }
  function getDataURL() {
    return chart.value.getDataURL();
  }
  defineExpose({
    getChart,
    getDataURL,
    updateChart
  });