潘志宝
2024-10-31 13c97d76348b5451381320aa54efa0706f38ecb6
src/views/data/point/DaPointChart.vue
@@ -63,9 +63,9 @@
    endTime: undefined,
  });
  const queryParams = reactive({
    pointNo: "",
    start: undefined,
    end: undefined,
    codes: [],
    startDate: undefined,
    endDate: undefined,
  })
  function getYMDHMS() {
    let timestamp = new Date().getTime();
@@ -119,34 +119,27 @@
    visible.value = true;
    if (dataForm.value.id) {
      try {
        queryParams.pointNo=dataForm.value.pointNo;
        queryParams.start = dataForm.value.startTime;
        queryParams.end = dataForm.value.endTime;
        queryParams.codes=[dataForm.value.pointNo];
        queryParams.startDate = dataForm.value.startTime;
        queryParams.endDate = dataForm.value.endTime;
        const data = await DaPoint.getPointDaChart(queryParams)
        const dataList = [];
        const xAxisData = [];
        data[dataForm.value.pointNo].forEach(function (value) {
          // 判断数据是否为布尔型
          if (typeof value["value"] === "boolean") {
            value["value"] = value["value"]? 1 : 0;
          }
          dataList.push([value["time"], value["value"]]);
          xAxisData.push(value["time"]);
        });
        let seriesData = [];
        seriesData.push({
          name: "采集值",
          type: "line",
          data: dataList,
          showSymbol: false,
          smooth: false,
          lineStyle: {
            normal: {
              color: "#5B8FF9",
              width: 1,
        let seriesData = []
        data.series.forEach(item => {
          seriesData.push({
            name: item.name,
            type: "line",
            data: item.data,
            showSymbol: true,
            smooth: false,
            lineStyle: {
              normal: {
                color: "#5B8FF9",
                width: 1,
              },
            },
          },
        });
          });
        })
        myChart = echarts.init(chartDom.value);
        const option = {
          title: {
@@ -182,7 +175,7 @@
          xAxis: {
            type: "category",
            boundaryGap: false,
            data: xAxisData,
            data: data.categories,
          },
          yAxis: {
            type: "value",
@@ -194,7 +187,6 @@
          ],
          series: seriesData,
        };
        myChart.clear();
        myChart.setOption(option);
      } catch (error) {
        console.error(error)