【问题标题】:Vue3 Apexcharts: X-axis not showing dates properlyVue3 Apexcharts:X 轴未正确显示日期
【发布时间】:2021-09-29 16:26:06
【问题描述】:

我对 Apexchart 的日期时间 x 轴有疑问:

它应该只显示 26.09、27.09 和 28.09,并且每个刻度都应该与柱对齐。

这是我正在使用的数据:

[{
    "x": 1632614400000,
    "y": 1548.0806194763181
},
{
    "x": 1632700800000,
    "y": 2983.7424364471435
},
{
    "x": 1632787200000,
    "y": 606.8401075286865
}]

我已经尝试更改 x 轴的“tickAmount”,但没有可接受的结果。 示例:tickAmount=3

     xaxis: {
      type: "datetime",
      labels: {
        formatter: function(val, timestamp) {
          return moment(timestamp).format("DD.MM");
        },
      },
      tickAmount: 3
    },

还有什么我可以尝试的吗?

谢谢!

【问题讨论】:

    标签: vue.js datetime vuejs3 axis apexcharts


    【解决方案1】:

    尝试使用这种数据格式:

    [{
      name: 'Example name', 
      data: 
          [[1632614400000,1548.0806194763181],
          [1632614400000,1548.0806194763181]]
      }]

    【讨论】:

    • 不幸的是仍然是相同的行为
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-04
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多