Angular 6 Ngx图,xAxis日期排序错误

时间:2018-09-06 13:26:10

标签: ngx-charts

我需要对图表的x轴刻度进行排序。我尝试使用[xAxisTicks],但是没有用。我找不到与xAxisTicks相关的任何示例。我试图在其中分配一个变量,例如:

values = ["2012","2013","2014","2015","2016"];

另一个有趣的事情是,我的系列已经排序,但仍然显示未排序。

Chart object (series)

See chart's x-Axis

1 个答案:

答案 0 :(得分:0)

除非您使用时间序列(请参阅https://github.com/swimlane/ngx-charts/issues/434),否则序列“名称”只是字符串,并且当该序列不包含相同的“名称”集时似乎不会进行排序。但是,您可以调整数据以填写“缺失”系列条目

export var multi = [
  {
    "name": "memzuc",
    "series": [
      {
        "name": "201801",  // Added
        "value": 0
      },
      {
        "name": "201802",  // Added
        "value": 0
      },
      {
        "name": "201803",
        "value": 350855
      },
      {
        "name": "201804",
        "value": 351673
      },
      {
        "name": "201805",
        "value": 368720
      },
      {
        "name": "201806",
        "value": 366941
      },
      {
        "name": "201807",
        "value": 387829
      },
    ]
  },

  {
    "name": "cwb",
    "series": [
      {
        "name": "201801",
        "value": 342300
      },
      {
        "name": "201802",
        "value": 337298
      },
      {
        "name": "201803",
        "value": 350855
      },
      {
        "name": "201804",
        "value": 359973
      },
      {
        "name": "201805",
        "value": 2179919
      },
      {
        "name": "201806",  // Added
        "value": 0
      },
      {
        "name": "201807",  // Added
        "value": 0
      }
    ]
  }
];

请参见https://plnkr.co/edit/RQKpXjAYcocqpTUHZWUo