This is a migrated thread and some comments may be shown as answers.

How to sort funnel chart using category axis

3 Answers 356 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Boyan
Top achievements
Rank 1
Boyan asked on 21 Feb 2020, 09:10 AM

Hi,

I'm trying to follow this example - https://www.telerik.com/forums/best-way-to-dynamically-build-pareto-chart and sort the funnel chart using the dataBound event, but unfortunately it doesn't work. Please check my dojo - http://dojo.telerik.com/OJUcikOr . My requirements are to group the data by the category property and then to sort it desc. 

Waiting for an advice.

Best Regards, Boyan.

3 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 25 Feb 2020, 09:01 AM

Hi, Boyan,

To sort the groups values by descending, you can just add the group.dir to be "desc".

If I understand the requirement correctly, then that would position the category with higher value at the top of the funnel without the need for the dataBound event:

[Dojo]

 group: {
    field: "category", dir: "desc",
    aggregates: [{ field: "value", aggregate: "sum" }]
}

In case this is not the desired outcome, please explain in more details or with a sketch and notes what is, so I can provide an alternative suggestion.

Finally, the Funnel Chart is not a categorical chart, but a single series chart and this is why the referenced approach did not work.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Boyan
Top achievements
Rank 1
answered on 25 Feb 2020, 07:08 PM

Hi Alex, 

Thanks for your reply. 

My requirements description was not so clear, but you have answered my question with your final sentence. The idea is to sort the values to achieve a descending funnel. I ended up with the solution to sort the data before bind to chart.

chartData = chartData.sort(function compare(a, b) {
                    if (a.value > b.value)
                        return -1;
                    else if (a.value < b.value)
                        return 1;
                    else return 0;
                });

Here is the dojo

Thanks again.

Boyan.

 

0
Alex Hajigeorgieva
Telerik team
answered on 27 Feb 2020, 01:32 PM

Hi, Boyan,

Excellent news! Thank you very much for updating the thread as well. It could be very helpful to someone trying to accomplish a similar outcome.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Charts
Asked by
Boyan
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Boyan
Top achievements
Rank 1
Share this question
or