0

I am using react-apexcharts to display data on chart. Chart display data from ascending order like from January to December but I need to display in descending order like from December to January.

Is there any option to change the order.

4

1 回答 1

0

数据的顺序取决于您在将数据传递给系列选项之前如何构建 x 轴类别(Jan ... Dec 或 Dec ... Jan)和数据数组。由于您使用的是反应版本,我假设您从 ajax 调用中获取数据。假设你有这样的初始状态:

this.state = {
  options: {
    ...
    xaxis: {
      categories: [],
    },
    noData: {
      text: "Loading...",
    },
  },
  series: [],
};

您需要做的是,您可以配置后端以返回为 x 轴类别和系列准备好的数据,或者按原样接收并在前端对其进行排序,然后相应地设置状态。

于 2020-05-01T14:50:57.073 回答