44919

Angular 6 Ngx-charts, xAxis date sorting is wrong

Question:

I need to sort x-axis ticks of the chart. I tried to use [xAxisTicks], but it didn't work. I couldn't find any example related with xAxisTicks. I tried to assign a variable inside of it like:

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

Another interesting thing is, My series is already sorted but it still shows unsorted.

<a href="https://i.stack.imgur.com/XnhL2.png" rel="nofollow">Chart object (series)</a>

<a href="https://i.stack.imgur.com/shan6.png" rel="nofollow">See chart's x-Axis</a>

Answer1:

Unless you're using a time series (see <a href="https://github.com/swimlane/ngx-charts/issues/434" rel="nofollow">https://github.com/swimlane/ngx-charts/issues/434</a> ), the series 'names' are just strings and don't appear to get sorted when the series don't contain the same sets of 'names'. You can, however, adjust the data to fill in the 'missing' series entries,

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 } ] } ];

see <a href="https://plnkr.co/edit/RQKpXjAYcocqpTUHZWUo" rel="nofollow">https://plnkr.co/edit/RQKpXjAYcocqpTUHZWUo</a>

Recommend

  • Linq to SQL order by with Distinct
  • Using both sort & filter on a QuerySet
  • Bubble Sort Display
  • How to increase the python speed over loops?
  • Plotly and ggplot with facet_grid in R: How to to get yaxis labels to use ticktext value instead of
  • C++ calling the default constructor with parens vs without parens [duplicate]
  • angular2 chart and events
  • Find first match in table range
  • Keep same scale in different graphs ggplot2
  • JFreechart X and Y axis scaling
  • Cassandra: What is a subcolumn
  • Python find continuous interesctions of intervals
  • Scala using regex with or syntax in match case statement
  • HighCharts - Show tooltip on column where value is 0 or null
  • Convert two columns Pandas data frame to dictionary of list with first column as keys
  • How to turn (A, B, C) into (AB, AC, BC) with Pig?
  • Create function that can pass a parameter without making a new component
  • select function not working in 3.5.4 version of d3.js
  • C# List of Panels
  • Breaking out column by groups in Pandas
  • Sort List of Strings By Version
  • How to suppress a dialog
  • How to Cache Real-time Data?
  • Get data from AJAX - How to
  • RectangularRangeIndicator format like triangular using dojo
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Controls, properties, events and timers running in design time
  • Cross-Platform Protobuf Serialization
  • Does CUDA 5 support STL or THRUST inside the device code?
  • Updated Ionic CLI but shows previous version (Windows)
  • AT Commands to Send SMS not working in Windows 8.1
  • Revoking OAuth Access Token Results in 404 Not Found
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How do I configure my settings file to work with unit tests?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • Is it possible to post an object from jquery to bottle.py?
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass