How to sort the value of the stacking bar chart and display it in descending order
Application Type
Reactive

Hello,

I had a problem with sorting the value of the bar of the stacking bar (column) chart and display it in descending (or ascending) order.

For example, as the below figure:


What I would need it to be improved is:

The bar is sorted by value of its bar in descending order and as in the figure, we can guest the order of the bar should be like that:  Pears, Grapes, Apples, Oranges, Bananas,... as below figure:


Of course, I am working with the outsystems for this problem but for easier problem solving I gonna leave here the link of the example of HighChartJSon for stacking bar chart, hope so one can work directly with this example and help me solve it. 

Stacked bar - JSFiddle - Code Playground

Thank you for your interesting. I am so much looking forward to hearing from you.

Best regards,

Nguyen Phuoc Luc.

Solution

Hi @Luc Nguyen,

This looks an issue/limitation on the provider side. I've search for a workaround but I didn't get it yet.

Useful Links:


I think the only solution for this is:

  1. Calculate the stacked value, after fetching the data;
  2. Get the order of categories respecting the calculation
  3. Build a Datapoints' list where the datapoints are sorted respecting the order of categories.


Sorry for this block on your journey, let me know if this helps you,

Best Regards,
João Ferreira


Hello Ferreira,

Thank you for your reply. Let me approach highchart forum for seeking the advices. However I also agree with your solution that we have to use some advanced data query and sort the data before assigning it to the Datapoint list.

Best regards,

Phuoc Luc

Hello Luc Nguyen!

You can achieve this using the following code on your Advance Format -> HighCharts JSON option

  "plotOptions: {
    series: {
      stacking: 'normal',
      dataSorting: {
        enabled: true,
        sortKey: 'y'
      }
    }
  }"

This will ensure that your data can be dynamic and sorted!

I will leave an oml so you can check the code, I even recreated the data from the fiddle. 

Hope it helps! 

Paulo Rosário

BarChartSort.oml

Hello @Paulo Rosário  ,

Thank you so much for your reply.

But the data is still not correct, the order of the bar should be like that:  Pears, Grapes, Apples, Oranges, Bananas,... as below figure: 

Hope you can know how to fix the issue! Thanks very much for your great support.

Best regards,

Phuoc Luc

Solution

Hi @Luc Nguyen,

This looks an issue/limitation on the provider side. I've search for a workaround but I didn't get it yet.

Useful Links:


I think the only solution for this is:

  1. Calculate the stacked value, after fetching the data;
  2. Get the order of categories respecting the calculation
  3. Build a Datapoints' list where the datapoints are sorted respecting the order of categories.


Sorry for this block on your journey, let me know if this helps you,

Best Regards,
João Ferreira


Hello Ferreira,

Thank you for your reply. Let me approach highchart forum for seeking the advices. However I also agree with your solution that we have to use some advanced data query and sort the data before assigning it to the Datapoint list.

Best regards,

Phuoc Luc

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.