Datasource Sort not working on Chart

1 Answer 13 Views
Charts Data Source
Scott
Top achievements
Rank 1
Scott asked on 08 Sep 2022, 03:05 PM

I want the chart in this dojo example to be in descending order.   Currently it is in ascending order.  I used the sort on the datasource but it doesn't seem to be reflecting in the chart.   I'm sure i am missing something simple here but any help would be appreciated. 

https://dojo.telerik.com/UNENAfos

Thanks.  

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Denchev
Telerik team
answered on 13 Sep 2022, 11:54 AM

Hi, Scott,

Thank you for providing a runnable sample.

In this case, it seems like you want to sort the categories so you should perform the sorting on the categoryAxis.categories array directly. You can use the dataBound event to ensure all of the data has loaded before you perform the operation.

        dataBound: function(e) {
          var axis = e.sender.options.categoryAxis;
          axis.categories = axis.categories.sort();
        }

Dojo

https://dojo.telerik.com/@gdenchev/OVarOgIW 

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Scott
Top achievements
Rank 1
commented on 13 Sep 2022, 03:46 PM | edited

Ok, so your answer got me moving in the right direction.   Your example did sort the chart but unfortunately it sorted by month alphabetically (April,February,January,March,May) instead of descending chronologically.  So that got me thinking about using a Julian Date.   So I added the Julian Date to the dataset and set that as the category axis.  I then used the template to display it as a date format.   Here is the dojo that I ended up with.   Dojo Example
Georgi Denchev
Telerik team
commented on 16 Sep 2022, 08:37 AM

Hi, Scott,

Thank you for sharing the full approach!

I am certain it will be of help to someone who stumbles across the same problem in the future.

Best Regards,

Georgi

Tags
Charts Data Source
Asked by
Scott
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or