调整窗口大大后,仅加载数据

发布于 2025-02-09 06:56:08 字数 1773 浏览 6 评论 0原文

我正在使用代码上的ApexChart显示带有一些数据的图表,但是当页面加载时,我的数据不会显示,仅显示我缩放/缩小/缩小或调整窗口大小时,我发现有点奇怪。 我在Apexcharts github上找到了类似的问题,但是自2019年以来一直开放,并且并非真正活跃,所以我在这里问,也许有人有相同的问题并找到了某种方法来解决它。


这是我的ApexChart:

<v-col cols="12">
 <apexchart
  type="line"
  height="350"
  :options="chartOptions"
  :series="series"
 ></apexchart>
</v-col>

这是我的ChartOptions:

chartOptions: {
    chart: {
      height: 350,
      type: "line",
      zoom: {
        enabled: false,
      },
      toolbar: {
        show: false,
      },
    },
    legend: {
      labels: {
        colors: "#FFFFFF",
      },
    },
    dataLabels: {
      enabled: false,
    },
    stroke: {
      curve: "straight",
    },
    title: {
      align: "left",
    },
    grid: {
      row: {
        colors: ["#f3f3f3", "transparent"], // takes an array which will be repeated on columns
        opacity: 0.5,
      },
    },
    xaxis: {
      type: "datetime",
      categories: [],
      labels: {
        datetimeUTC: false,
        style: {
          colors: "#FFFFFF",
        },
      },
    },
    yaxis: [
      {
        title: {
          text: "Energie",
          style: {
            color: "#FFFFFF",
          },
        },
        labels: {
          style: {
            colors: "#FFFFFF",
          },
        },
        decimalsInFloat: 1,
      },
      {
        opposite: true,
        title: {
          text: "Puissance",
          style: {
            color: "#FFFFFF",
          },
        },
        labels: {
          style: {
            colors: "#FFFFFF",
          },
        },
        decimalsInFloat: 1,
      },
    ],
    tooltip: {
      enabled: false,
    },
    colors: ["#8AB4F7", "#8DCD7F"],
  },

I am using an apexchart on my code to display a chart with some data, however my data is not shown when the page loads, it only shows if I zoom in/zoom out or resize the window which I find kinda weird.
I've found a similar issue on the apexcharts github but it has been open since 2019 and is not really active so I'm asking here maybe someone had the same issue and found some way to fix it.


Here's my apexchart:

<v-col cols="12">
 <apexchart
  type="line"
  height="350"
  :options="chartOptions"
  :series="series"
 ></apexchart>
</v-col>

Here's my chartOptions:

chartOptions: {
    chart: {
      height: 350,
      type: "line",
      zoom: {
        enabled: false,
      },
      toolbar: {
        show: false,
      },
    },
    legend: {
      labels: {
        colors: "#FFFFFF",
      },
    },
    dataLabels: {
      enabled: false,
    },
    stroke: {
      curve: "straight",
    },
    title: {
      align: "left",
    },
    grid: {
      row: {
        colors: ["#f3f3f3", "transparent"], // takes an array which will be repeated on columns
        opacity: 0.5,
      },
    },
    xaxis: {
      type: "datetime",
      categories: [],
      labels: {
        datetimeUTC: false,
        style: {
          colors: "#FFFFFF",
        },
      },
    },
    yaxis: [
      {
        title: {
          text: "Energie",
          style: {
            color: "#FFFFFF",
          },
        },
        labels: {
          style: {
            colors: "#FFFFFF",
          },
        },
        decimalsInFloat: 1,
      },
      {
        opposite: true,
        title: {
          text: "Puissance",
          style: {
            color: "#FFFFFF",
          },
        },
        labels: {
          style: {
            colors: "#FFFFFF",
          },
        },
        decimalsInFloat: 1,
      },
    ],
    tooltip: {
      enabled: false,
    },
    colors: ["#8AB4F7", "#8DCD7F"],
  },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

π浅易 2025-02-16 06:56:08

将REF设置为图表&lt; ApexChart Ref =“ Chart_ref”/&GT;并调用以下行:

this.$refs.chart_ref.refresh()

您还可以将此行包裹在NextTick或SettimeTimeOut(0)中,如果仍在错误。

Set a ref to your chart <apexchart ref="chart_ref"/> and call following line:

this.$refs.chart_ref.refresh()

You can also wrap this line in nextTick or setTimeout (0) if still bugging.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文