echarts tooltip提示框显示不全

news2025/2/26 14:22:34

一、背景:

写在前面:

自行封装。一个可由多个柱形图叠加而成的图表,命名为someHoverLine(可自定义)。

下面罗列了移动端和web端的封装组件代码;

展示了vue2、uniapp、vue3的不同封装和使用案列。

二、问题描述:

三、解决办法:

办法一:

tooltip: {
   confine: true,
}

实际代码:

 

效果展示:

 

办法二:

tooltip: {
   appendToBody: true
},

实际代码:

实际效果:

 

推荐使用第一种方法。。。 

写到这儿就完毕了。

下面是封装的一个图表组件,一个由很多柱形图组成的叠加柱形图。。。

四、封装组件:

移动端:

效果展示:

移动端,vue2、uniapp写法:

封装组件: 


//封装组件
//vue2、uniapp
<template>
  <view class="reMoreBar_home" :style="{ width: width, height: height }">
    <view
      ref="dbBarRef"
      :id="echartsId"
      :style="{ width: width, height: height }"
    ></view>
  </view>
</template>

<script module="echarts" lang="renderjs">
import { getAssetsFile, fontSize, nowResize } from "@/utils/index.js";
import * as echarts from "echarts";

let myEcharts;

export default {
  props: {
    echartsId: {
      type: String,
      default: "dbBarRef",
      required: true,
    },
    width: {
      type: String,
      default: "100%",
    },
    height: {
      type: String,
      default: "100%",
    },
    names: {
      type: Array,
      default: [
        // "蓄电池#1/Ah",
        // "蓄电池#2/Ah",
        // "蓄电池#3/Ah",
        // "蓄电池#4/Ah",
        // "蓄电池#5/Ah",
        // "蓄电池#6/Ah",
        // "蓄电池#7/Ah",
      ],
    },
    linxs: {
      type: Array,
      default: [
        // "2024-01-21 15:002",
        // "2024-01-21 15:01",
        // "2024-01-21 15:02",
        // "2024-01-21 15:03",
        // "2024-01-21 15:04",
        // "2024-01-21 15:05",
        // "2024-01-21 15:06",
        // "2024-01-21 15:07",
        // "2024-01-21 15:08",
        // "2024-01-21 15:09",
        // "2024-01-21 15:10",
        // "2024-01-21 15:11",
        // "2024-01-21 15:12",
        // "2024-01-21 15:13",
        // "2024-01-21 15:14",
        // "2024-01-21 15:15",
      ],
    },
    values: {
      type: Array,
      default: [
        // [
        //   580, 236, 217, 534, 580, 236, 217, 580, 151, 231, 0, 192, 453, 524, 165,
        //   0,
        // ],
        // [
        //   625, 345, 65, 192, 120, 180, 192, 80, 150, 153, 152, 128, 125, 625, 345,
        //   65,
        // ],
        // [
        //   4510, 352, 303, 534, 328, 159, 151, 192, 330, 151, 231, 192, 328, 159,
        //   151, 536,
        // ],
        // [
        //   120, 125, 0, 192, 120, 180, 0, 220, 125, 80, 192, 120, 125, 145, 65,
        //   125,
        // ],
        // [
        //   545, 80, 192, 330, 580, 236, 217, 328, 159, 151, 580, 236, 217, 524,
        //   165, 236,
        // ],
        // [
        //   360, 545, 360, 545, 80, 192, 80, 28, 625, 453, 80, 28, 625, 345, 65,
        //   105,
        // ],
        // [220, 125, 28, 625, 345, 65, 325, 80, 150, 153, 0, 128, 0, 220, 125, 80],
      ],
    },
    colors: {
      type: Array,
      default: [
        "rgba(266, 102, 304)",
        "rgba(0, 121, 202)",
        "rgba(247,220,111)",
        "rgba(0, 202, 104)",
        "rgba(909, 66, 22)",
        "rgba(100, 50, 102)",
        "rgba(147,120,211)",
        "rgba(245,107,184)",
        "rgba(35,172,201)",
        "rgba(66, 199, 102)",
        "rgba(241,148,138)",
        "rgba(130,182,220)",
      ],
    },
    xUnit: {
      type: String,
      default: "单位",
    },
    yUnit: {
      type: String,
      default: "单位",
    },
    // legendStyle: {
    //   type: Object,
    //   default: {
    //     fontSize: 12,
    //     color: "#000",
    //     top: "5%",
    //     left: "10%",
    //   },
    // },
    // 图表x,y轴定制
    xType: {
      type: String,
      default: "category",
    },
    unitX: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      myCharts: null,
    };
  },
  methods: {
    init() {
      let charts = {
        unit: this.yUnit || "数值",
        names: this.names,
        lineX: this.linxs,
        value: this.values,
        colors: this.colors,
        xType: this.xType,
        xUnit: this.xUnit,
        yUnit: this.yUnit,
      };
      let lineY = [];
      for (var i = 0; i < charts.names.length; i++) {
        let seriesItem = {
          name: charts.names[i],
          type: "bar",
          barMaxWidth: 36,
          stack: "Ad",
          emphasis: {
            focus: "series",
          },
          itemStyle: {
            // color: "#5CB1FF",
            color: charts.colors[i],
          },
          data: charts.value[i],
          label: {
            show: true,
            color: "#fff",
          },
        };
        lineY.push(seriesItem);
      }
      let option = {
        tooltip: {
          trigger: "axis",
          // confine: true,//是否将 tooltip 框限制在图表的区域内。
          appendToBody: true,//是否提示框的 DOM 节点添加为 HTML 的 的子节点;默认为本图表的 DOM container 的一个子孙节点
          axisPointer: {
            type: "shadow",
          },
          formatter: function (params) {
            let myTimer = params[0].axisValue.split(" ")[0];
            let totalValue;
            totalValue = params
              .map((item) => item.value)
              .reduce((a, b) => a + b);
            let str =
              "时间:" +
              myTimer +
              " 总消耗:" +
              totalValue.toFixed(2) +
              charts.yUnit;
            for (let i in params) {
              str =str+"<br/>" +
                params[i].marker +
                params[i].seriesName +
                " " +
                params[i].value +
                charts.yUnit;
            }
            return str;
          },
        },
        // legend: {},
        legend: {
          data: charts.names,
          type: "scroll",
          top: "2%",
          left: "5%",
          // left: "right",
          // icon: "circle",
        },
        dataZoom: [
          {
            type: "inside", //1平移 缩放。
            // zoomLock: true, //如果设置为 true 则锁定选择区域的大小,也就是说,只能平移,不能缩放。
            preventDefaultMouseMove: false,
          },
        ],
        grid: {
          left: "1%",
          right: "1%",
          bottom: "2%",
          containLabel: true,
        },
        xAxis: {
          name: charts.xType === "value" ? charts.xUnit : "",
          nameTextStyle: {
            color: "#000",
            fontSize: nowResize(24),
          },
          type: charts.xType,
          data: charts.lineX,
          // maxInterval: 3600 * 1000 * 24,
          boundaryGap: true, // 留白
          splitLine: {
            show: false,
            lineStyle: {
              type: "dotted",
              color: "rgba(255,255,255,0.2)",
            },
          },
          axisLabel: {
            color: "#000",
            fontSize: nowResize(32),
            symbol: [
              "none",
              "path://M5,20 L5,5 L8,8 L5,2 L2,8 L5,5 L5.3,6 L5.3,20",
            ],
            formatter: function (params) {
              // return params.split(" ")[0];
              // return params.replace(' ', '\n')
              let arr = params.split(" ");
              let space = "\n";
              // const myFormatter =
              //   arr[0]?.slice(5) + space + arr[1]?.substring(0, 5);
              const myFormatter = arr[0]?.slice(5);
              return myFormatter;
            },
          },
          axisLine: {
            symbol: ["none", "arrow"],
            symbolOffset: 6,
            symbolSize: [5, 8],
            lineStyle: {
              color: "rgba(104,143,179)",
              width: nowResize(1),
              type: "solid",
            },
          },
          axisTick: {
            show: false,
          },
        },
        yAxis: {
          name: charts.xType !== "value" ? `单位/${charts.yUnit}` : "单位/",
          nameTextStyle: {
            color: "#000",
            fontSize: nowResize(44),
          },
          type: charts.xType === "value" ? "category" : "value",
          minInterval: charts.xType !== "value" && 10,
          data: charts.lineX,
          splitLine: {
            lineStyle: {
              type: "dotted",
              color: "rgba(255,255,255,0.2)",
            },
          },
          axisLabel: {
            interval: 0,
            color: "#000",
            fontSize: nowResize(32),
            formatter: (value) => {
              return Math.ceil(value); // 向上取整,去除小数
            },
          },
          axisLine: {
            symbol: ["none", "arrow"],
            symbolOffset: 6,
            symbolSize: [5, 8],
            lineStyle: {
              color: "rgba(104,143,179)",
              width: nowResize(1),
              type: "solid",
            },
          },
          axisTick: {
            show: false,
          },
        },
        series: lineY, //接口数据
        // series: [
        //   {
        //     name: "Email",
        //     type: "bar",
        //     stack: "Ad",
        //     emphasis: {
        //       focus: "series",
        //     },
        //     itemStyle: {
        //       color: "#4279CA",
        //     },
        //     data: [
        //       120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210,
        //     ],
        //     label: {
        //       show: true,
        //       textStyle: {
        //         color: "#fff",
        //       },
        //     },
        //   },
        //   {
        //     name: "Union Ads",
        //     type: "bar",
        //     stack: "Ad",
        //     emphasis: {
        //       focus: "series",
        //     },
        //     itemStyle: {
        //       color: "#2FE1E1",
        //     },
        //     data: [
        //       220, 182, 191, 234, 290, 330, 310, 120, 132, 101, 134, 90, 230, 210,
        //     ],
        //     label: {
        //       show: true,
        //       textStyle: {
        //         color: "#fff",
        //       },
        //     },
        //   },
        //   {
        //     name: "Video Ads",
        //     type: "bar",
        //     stack: "Ad",
        //     emphasis: {
        //       focus: "series",
        //     },
        //     itemStyle: {
        //       color: "#5CB1FF",
        //     },
        //     data: [
        //       150, 232, 201, 154, 190, 330, 410, 120, 132, 101, 134, 90, 230, 210,
        //     ],
        //     label: {
        //       show: true,
        //       textStyle: {
        //         color: "#fff",
        //       },
        //     },
        //   },
        // ],
      };
      option && this.myCharts && this.myCharts.setOption(option, true);
    },
    end() {
      this.myCharts && this.myCharts.dispose();
      window.removeEventListener("resize", function () {
        this.myCharts && this.myCharts.resize();
      });
      this.myCharts = null;
    },
  },
  mounted() {
    this.$nextTick(() => {
      this.myCharts = echarts.init(
        document.getElementById(this.echartsId),
        null,
        {
          renderer: "svg",
        }
      );
      window.addEventListener("resize", function () {
        this.myCharts && this.myCharts.resize();
      });
      this.init();
    });
  },
  beforeMount() {
    this.end();
  },
  watch: {
    option: {
      handler: function (newV, olgV) {
        this.myCharts.clear();
        this.init();
      },
      deep: true,
    },
    names: {
      handler: function (newV, olgV) {
        this.myCharts.clear();
        this.init();
      },
      deep: true,
    },
    linxs: {
      handler: function (newV, olgV) {
        this.myCharts.clear();
        this.init();
      },
      deep: true,
    },
    values: {
      handler: function (newV, olgV) {
        this.myCharts.clear();
        this.init();
      },
      deep: true,
    },
  },
};
</script>
<style lang="scss" scoped>
.reMoreBar_home {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  #dbBarRef {
    width: calc(100vw - 13vw);
    height: 100%;
  }
}
</style>

组件使用案列:

//1.注册组件     
//2.使用组件
//3.组件传参            
                 <someHoverLine
                    echartsId="mainB"
                    :names="echartData.names"
                    :linxs="echartData.linxs"
                    :values="echartData.values"
                    :colors="echartData.colors"
                    :yUnit="echartData.yUnit"
                  />
this.echartData = {
            yUnit: "t",
            linxs: resTimeArr,
            names: ["主机油耗", "发电机组油耗", "锅炉油耗"],
            values: resNumArr,
            colors: [
              "rgba(93, 177, 251, 1)",
              "rgba(47, 226, 227, 1)",
              "rgba(64, 122, 204, 1)",
            ],
          };
let resTimeArr= [
    "2024-03-13",
    "2024-03-14",
    "2024-03-15",
    "2024-03-16",
    "2024-03-17",
    "2024-03-18",
    "2024-03-19",
    "2024-03-20",
    "2024-03-21",
    "2024-03-22",
    "2024-03-23",
    "2024-03-24",
    "2024-03-25",
    "2024-03-26",
    "2024-03-27",
    "2024-03-28",
    "2024-03-29"
]
let resNumArr = [
    [
        17.22,
        14.08,
        27.26,
        35.03,
        33.98,
        40.75,
        17.87,
        18.37,
        61.39,
        30.26,
        26.01,
        35.21,
        30.03,
        41.89,
        16.27,
        28.02,
        0
    ],
    [
        0,
        0,
        0.01,
        0,
        0,
        0.01,
        0,
        0,
        0.01,
        0,
        0,
        0.01,
        0,
        0,
        0,
        3.05,
        5.51
    ],
    [
        0,
        0,
        0,
        0,
        0.01,
        0,
        0,
        0.01,
        0.01,
        0.01,
        0,
        0.01,
        0.01,
        0.01,
        0,
        1.9,
        3.97
    ]
]

备注:

解决了toolTips提示框显示不全的问题。

解决办法:

confine: true,//是否将 tooltip 框限制在图表的区域内。 

web端: 

效果展示:

 封装组件:

//封装组件
//vue3 setup
<script setup>
import { Warning } from "@element-plus/icons-vue";
import { onMounted, onUnmounted, watch } from "vue";
import { getAssetsFile, fontSize } from "@/utils";
const _echarts = inject("$echarts");
const dbBarRef = ref(null);
const props = defineProps({
  width: {
    type: String,
    default: "100%",
  },
  height: {
    type: String,
    default: "100%",
  },
  names: {
    type: Array,
    default: [
      // "蓄电池#1/Ah",
      // "蓄电池#2/Ah",
      // "蓄电池#3/Ah",
      // "蓄电池#4/Ah",
      // "蓄电池#5/Ah",
      // "蓄电池#6/Ah",
      // "蓄电池#7/Ah",
    ],
  },
  linxs: {
    type: Array,
    default: [
      // "2024-01-21 15:002",
      // "2024-01-21 15:01",
      // "2024-01-21 15:02",
      // "2024-01-21 15:03",
      // "2024-01-21 15:04",
      // "2024-01-21 15:05",
      // "2024-01-21 15:06",
      // "2024-01-21 15:07",
      // "2024-01-21 15:08",
      // "2024-01-21 15:09",
      // "2024-01-21 15:10",
      // "2024-01-21 15:11",
      // "2024-01-21 15:12",
      // "2024-01-21 15:13",
      // "2024-01-21 15:14",
      // "2024-01-21 15:15",
    ],
  },
  values: {
    type: Array,
    default: [
      // [
      //   580, 236, 217, 534, 580, 236, 217, 580, 151, 231, 0, 192, 453, 524, 165,
      //   0,
      // ],
      // [
      //   625, 345, 65, 192, 120, 180, 192, 80, 150, 153, 152, 128, 125, 625, 345,
      //   65,
      // ],
      // [
      //   4510, 352, 303, 534, 328, 159, 151, 192, 330, 151, 231, 192, 328, 159,
      //   151, 536,
      // ],
      // [
      //   120, 125, 0, 192, 120, 180, 0, 220, 125, 80, 192, 120, 125, 145, 65,
      //   125,
      // ],
      // [
      //   545, 80, 192, 330, 580, 236, 217, 328, 159, 151, 580, 236, 217, 524,
      //   165, 236,
      // ],
      // [
      //   360, 545, 360, 545, 80, 192, 80, 28, 625, 453, 80, 28, 625, 345, 65,
      //   105,
      // ],
      // [220, 125, 28, 625, 345, 65, 325, 80, 150, 153, 0, 128, 0, 220, 125, 80],
    ],
  },
  colors: {
    type: Array,
    default: [
      "rgba(266, 102, 304)",
      "rgba(0, 121, 202)",
      "rgba(247,220,111)",
      "rgba(0, 202, 104)",
      "rgba(909, 66, 22)",
      "rgba(100, 50, 102)",
      "rgba(147,120,211)",
      "rgba(245,107,184)",
      "rgba(35,172,201)",
      "rgba(66, 199, 102)",
      "rgba(241,148,138)",
      "rgba(130,182,220)",
    ],
  },
  xUnit: {
    type: String,
    default: "单位",
  },
  yUnit: {
    type: String,
    default: "单位",
  },
  legendStyle: {
    type: Object,
    default: {
      fontSize: 12,
      color: "#000",
      top: "5%",
      left: "10%",
    },
  },
  // 图表x,y轴定制
  xType: {
    type: String,
    default: "category",
  },
  unitX: {
    type: String,
    default: "",
  },
});
let myEcharts;
onMounted(() => {
  nextTick(() => {
    myEcharts = _echarts.init(dbBarRef.value, null, {
      renderer: "svg",
    });
    window.addEventListener("resize", function () {
      myEcharts && myEcharts.resize();
    });
    _init();
  });
});
onUnmounted(() => {
  _end();
});
watch(
  () => props.names,
  (val) => {
    if (val) {
      nextTick(() => {
        _init();
      });
    }
  }
);
watch(
  () => props.linxs,
  (val) => {
    if (val) {
      nextTick(() => {
        _init();
      });
    }
  }
);
watch(
  () => props.values,
  (val) => {
    if (val) {
      nextTick(() => {
        _init();
      });
    }
  }
);
const _init = () => {
  let charts = {
    unit: props.yUnit || "数值",
    names: props.names,
    lineX: props.linxs,
    value: props.values,
    colors: props.colors,
    xType: props.xType,
    xUnit: props.xUnit,
    yUnit: props.yUnit,
  };
  let lineY = [];
  for (var i = 0; i < charts.names.length; i++) {
    let seriesItem = {
      name: charts.names[i],
      type: "bar",
      barMaxWidth: 36,
      stack: "Ad",
      emphasis: {
        focus: "series",
      },
      itemStyle: {
        // color: "#5CB1FF",
        color: charts.colors[i],
      },
      data: charts.value[i],
      label: {
        show: false,
        color: "#fff",
      },
    };
    lineY.push(seriesItem);
  }
  let option = {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
      formatter: function (params) {
        let myTimer = params[0].axisValue.split(" ")[0];
        let totalValue;
        totalValue = params.map((item) => item.value).reduce((a, b) => a + b);
        let str =
          "时间:" +
          myTimer +
          " 总消耗:" +
          totalValue.toFixed(2) +
          charts.yUnit;
        for (let i in params) {
          str =str+"<br/>" +
            params[i].marker +
            params[i].seriesName +
            " " +
            params[i].value +
            charts.yUnit;
        }
        // const marker1 = params[0].marker;
        // const seriesName1 = params[0].seriesName;
        // const myValue1 = params[0].value;
        // const marker2 = params[1].marker;
        // const seriesName2 = params[1].seriesName;
        // const myValue2 = params[1].value;
        // const marker3 = params[2].marker;
        // const seriesName3 = params[2].seriesName;
        // const myValue3 = params[2].value;
        // const str1 = marker1 + seriesName1 + " " + myValue1 + charts.yUnit;
        // const str2 = marker2 + seriesName2 + " " + myValue2 + charts.yUnit;
        // const str3 = marker3 + seriesName3 + " " + myValue3 + charts.yUnit;
        // const str =
        //   "时间:" +
        //   myTimer +
        //   " 总消耗:" +
        //   totalValue.toFixed(2) +
        //   charts.yUnit +
        //   "<br/>" +
        //   str +
        //   "<br/>" +
        //   str2 +
        //   "<br/>" +
        //   str3;
        return str;
      },
    },
    // legend: {},
    legend: {
      data: charts.names,
      type: "scroll",
      top: "5%",
      left: "75%",
      // left: "right",
      // icon: "circle",
    },
    grid: {
      left: "1%",
      right: "1%",
      bottom: "2%",
      containLabel: true,
    },
    xAxis: {
      name: charts.xType === "value" ? charts.xUnit : "",
      nameTextStyle: {
        color: "#000",
        fontSize: fontSize(12),
      },
      type: charts.xType,
      data: charts.lineX,
      // maxInterval: 3600 * 1000 * 24,
      boundaryGap: true, // 留白
      splitLine: {
        show: false,
        lineStyle: {
          type: "dotted",
          color: "rgba(255,255,255,0.2)",
        },
      },
      axisLabel: {
        color: "#000",
        fontSize: fontSize(16),
        symbol: [
          "none",
          "path://M5,20 L5,5 L8,8 L5,2 L2,8 L5,5 L5.3,6 L5.3,20",
        ],
        formatter: function (params) {
          // return params.split(" ")[0];
          // return params.replace(' ', '\n')
          let arr = params.split(" ");
          let space = "\n";
          // const myFormatter =
          //   arr[0]?.slice(5) + space + arr[1]?.substring(0, 5);
          const myFormatter = arr[0]?.slice(5);
          return myFormatter;
        },
      },
      axisLine: {
        symbol: ["none", "arrow"],
        symbolOffset: 6,
        symbolSize: [5, 8],
        lineStyle: {
          color: "rgba(104,143,179)",
          width: fontSize(1),
          type: "solid",
        },
      },
      axisTick: {
        show: false,
      },
    },
    yAxis: {
      name: charts.xType !== "value" ? `单位/${charts.yUnit}` : "单位/",
      nameTextStyle: {
        color: "#000",
        fontSize: fontSize(16),
      },
      type: charts.xType === "value" ? "category" : "value",
      minInterval: charts.xType !== "value" && 10,
      data: charts.lineX,
      splitLine: {
        lineStyle: {
          type: "dotted",
          color: "rgba(255,255,255,0.2)",
        },
      },
      axisLabel: {
        interval: 0,
        color: "#000",
        fontSize: fontSize(16),
        formatter: (value) => {
          return Math.ceil(value); // 向上取整,去除小数
        },
      },
      axisLine: {
        symbol: ["none", "arrow"],
        symbolOffset: 6,
        symbolSize: [5, 8],
        lineStyle: {
          color: "rgba(104,143,179)",
          width: fontSize(1),
          type: "solid",
        },
      },
      axisTick: {
        show: false,
      },
    },
    series: lineY, //接口数据
    // series: [
    //   {
    //     name: "Email",
    //     type: "bar",
    //     stack: "Ad",
    //     emphasis: {
    //       focus: "series",
    //     },
    //     itemStyle: {
    //       color: "#4279CA",
    //     },
    //     data: [
    //       120, 132, 101, 134, 90, 230, 210, 120, 132, 101, 134, 90, 230, 210,
    //     ],
    //     label: {
    //       show: true,
    //       textStyle: {
    //         color: "#fff",
    //       },
    //     },
    //   },
    //   {
    //     name: "Union Ads",
    //     type: "bar",
    //     stack: "Ad",
    //     emphasis: {
    //       focus: "series",
    //     },
    //     itemStyle: {
    //       color: "#2FE1E1",
    //     },
    //     data: [
    //       220, 182, 191, 234, 290, 330, 310, 120, 132, 101, 134, 90, 230, 210,
    //     ],
    //     label: {
    //       show: true,
    //       textStyle: {
    //         color: "#fff",
    //       },
    //     },
    //   },
    //   {
    //     name: "Video Ads",
    //     type: "bar",
    //     stack: "Ad",
    //     emphasis: {
    //       focus: "series",
    //     },
    //     itemStyle: {
    //       color: "#5CB1FF",
    //     },
    //     data: [
    //       150, 232, 201, 154, 190, 330, 410, 120, 132, 101, 134, 90, 230, 210,
    //     ],
    //     label: {
    //       show: true,
    //       textStyle: {
    //         color: "#fff",
    //       },
    //     },
    //   },
    // ],
  };
  option && myEcharts && myEcharts.setOption(option, true);
};
const _end = () => {
  myEcharts && myEcharts.dispose();
  window.removeEventListener("resize", function () {
    myEcharts && myEcharts.resize();
  });
  myEcharts = null;
};
</script>

<template>
  <div
    class="reMoreBar_home"
    :style="{ width: props.width, height: props.height }"
  >
    <div
      ref="dbBarRef"
      id="dbBarRef"
      :style="{ width: props.width, height: props.height }"
    ></div>
  </div>
</template>

<style lang="less" scoped>
.reMoreBar_home {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  #dbBarRef {
    width: calc(100vw - 13vw);
    height: 100%;
  }
}
</style>

 组件使用案列:

//vue3组件使用
<someHoverLine
            :names="data.echartData.names"
            :linxs="data.echartData.linxs"
            :values="data.echartData.values"
            :colors="data.echartData.colors"
            :yUnit="data.echartData.yUnit"
          />
//组件的参数
data.echartData = {
        yUnit: "kg",
        linxs: resTimeArr,
        names: ["主机油耗", "发电机组油耗", "锅炉油耗"],
        values: resNumArr,
        colors: [
          "rgba(93, 177, 251, 1)",
          "rgba(47, 226, 227, 1)",
          "rgba(64, 122, 204, 1)",
        ],
      };
//备注:resTimeArr、resNumArr同上

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1585493.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

策略模式类图与代码

某大型购物中心欲开发一套收银软件&#xff0c;要求其能够支持购物中心在不同时期推出的各种促销活动&#xff0c;如打折、返利(例如&#xff0c;满300返100),等等。现采用策略(Strategy)模式实现该要求&#xff0c;得到如图7.13 所示的类图。 【Java 代码】 import java.util…

开源大数据集群部署(二十)Trino部署

作者&#xff1a;櫰木 1 解压trino的包到opt目录 cd /root/bigdata tar -xzvf trino-server-389.tar.gz -C /opt/ ln -s /opt/trino-server-389 /opt/trino2 创建trino用户&#xff0c;并配置专属jdk11 useradd trino su – trino chown -R trino:hadoop /opt/trino-server-…

git常用命令合集,程序员必备技能,5分钟学会

仓库相关操作 1.git remote -v 查看当前仓库地址 2.git remote add origin 仓库地址&#xff1a;给当前git项目添加远程仓库绑定 3.git branch -M main : 重命名当前分支为main 4.git push -u origin main&#xff1a;将当前(main)分支上的内容上传到刚刚添加的origin远程库…

Java集合List

List特有方法 经典多态写法 // 经典的多态写法 List<String> list new ArrayList<>();常用API&#xff1a;增删改查 // 添加元素 list.add("Java"); // 添加元素到指定位置 list.add(0, "Python");// 获取元素 String s list.get(0);// 修改…

【Python】报错ModuleNotFoundError: No module named fileName解决办法

1.前言 当我们导入一个模块时&#xff1a; import xxx &#xff0c;默认情况下python解释器会搜索当前目录、已安装的内置模块和第三方模块。 搜索路径存放在sys模块的path中。【即默认搜索路径可以通过sys.path打印查看】 2.sys.path.append() sys.path是一个列表 list ,它里…

如何在Ubuntu系统使用docker部署DbGate容器并发布至公网可访问

文章目录 1. 安装Docker2. 使用Docker拉取DbGate镜像3. 创建并启动DbGate容器4. 本地连接测试5. 公网远程访问本地DbGate容器5.1 内网穿透工具安装5.2 创建远程连接公网地址5.3 使用固定公网地址远程访问 本文主要介绍如何在Linux Ubuntu系统中使用Docker部署DbGate数据库管理工…

vue实现从本地上传头像功能

上传头像&#xff1a; <template><div><el-card class"box-card"><div slot"header" class"clearfix"><span>更换头像</span></div><div><!-- 图片、用来展示用户选择的头像 --><img…

2024年国内最受欢迎的10大热门城市

如果你还没有计划好2024年的旅游行程&#xff0c;不妨考虑这些热门城市&#xff0c;去感受它们的魅力吧&#xff01;在时光流转的车轮下&#xff0c;中国城市风貌日新月异&#xff0c;各具特色的城市正以其独特的魅力吸引着国内外的目光。 近日&#xff0c;依据大数据及网络热度…

功能强大的开源数据中台系统 DataCap 2024.03.1 发布

推荐一套基于 SpringBoot 开发的简单、易用的开源权限管理平台&#xff0c;建议下载使用: https://github.com/devlive-community/authx 推荐一套为 Java 开发人员提供方便易用的 SDK 来与目前提供服务的的 Open AI 进行交互组件&#xff1a;https://github.com/devlive-commun…

【next】Extra attributes from the server: mpa-version,mpa-extension-id

layout下面的标签添加 suppressHydrationWarning{true}

头歌-机器学习 第12次实验 Adaboost算法

第1关&#xff1a;什么是集成学习 任务描述 本关任务&#xff1a;根据本节课所学知识完成本关所设置的选择题。 相关知识 为了完成本关任务&#xff0c;你需要掌握&#xff1a;1.什么是集成学习。 什么是集成学习 集成学习方法是一种常用的机器学习方法&#xff0c;分为b…

vue3新手笔记

setup&#xff08;&#xff09;{}函数&#xff0c;是启动页面后&#xff0c;自动执行的一个函数。所有数据&#xff08;常量、变量&#xff09;、函数等等&#xff0c;都要return 出去。 ref函数(可用于基本数据类型&#xff0c;也可以用于复杂数据类型)&#xff1a;让页面上的…

【QT入门】 Qt自定义控件与样式设计之QSlider用法及qss

往期回顾&#xff1a; 【QT入门】 Qt自定义控件与样式设计之QCheckBox qss实现按钮开关-CSDN博客 【QT入门】 Qt自定义控件与样式设计之QPushButton点击按钮弹出菜单-CSDN博客 【QT入门】Qt自定义控件与样式设计之QProgressBar用法及qss-CSDN博客 【QT入门】 Qt自定义控件与样式…

MPT - 原理及应用

前文回顾 Merkle原理及应用Merkle代码实现Patricia原理及应用Patricia代码实现 什么是MPT&#xff08;Merkle Patricia Tree&#xff09;树 MPT树是一种数据结构&#xff0c;用于在以太坊区块链中高效地存储和检索账户状态、交易历史和其他重要数据。MPT树的设计旨在结合Merk…

激光点云-无监督语义分割方法

深度学习和人工智能是点云分割的良好且强大的解决方案,但语义分割对于数据处理方式能否更加简单和快速?如今,我们仍然关注深度学习,但人工智能是以数据为中心的。生成这些数据是一个劳动密集型的解决方案,我们是否可以尝试采用简单的无监督语义分割来有效地“预标记”点云…

【noVNC】使用noVNC实现浏览器远程VNC(基于web的远程桌面)

一、操作的环境 windows 10系统乌班图 Ubuntu 22 二、noVNC 部署方式 原理&#xff1a;开启 Websockify 代理来做 WebSocket 和 TCP Socket 之间的转换 2.1 noVNC和VNC服务端同一台机器 使用方式&#xff0c;查看另一篇博文 &#xff1a;【noVNC】使用noVNC实现浏览器网页访…

基于8086方波信号发生器仿真设计

**单片机设计介绍&#xff0c;基于8086方波信号发生器仿真设计 文章目录 一 概要二、功能设计设计思路 三、 软件设计原理图 五、 程序六、 文章目录 一 概要 二、功能设计 文件夹内包含工程文件&#xff0c;可直接运行或者二次开发&#xff1b; 此设计可作为毕业设计和课程…

从“看见”工程活动和研发模式开始,提升团队工程交付能力

提升团队工程交付能力&#xff0c;从“看见”工程活动和研发模式开始 理想中的研发团队应当具有以下特征&#xff1a; 总是工作在最高优先级的事项上理想的研发团队能够识别并始终集中精力在当前最紧迫和最有价值的任务上。这需要团队具备出色的项目管理能力和决策能力&#x…

andorid 矢量图fillColor设置无效

问题&#xff1a;andorid 矢量图fillColor设置无效 解决&#xff1a;去掉如下 android:tint一行

考研数学|全程跟汤家凤,还是强化换张宇?

考研高数的复习策略因人而异&#xff0c;选择跟哪位老师的课程取决于个人的学习习惯、基础水平和目标院校的要求。 汤家凤老师的教学特点是注重基础知识的讲解和概念的理解&#xff0c;适合基础薄弱或者零基础的考生。他的课程通常从基础概念讲起&#xff0c;逐步深入&#xf…