Incubator-superset: Ordering on X axis on the distribution bar chart

Created on 26 May 2016  路  19Comments  路  Source: apache/incubator-superset

Hi all,

I have a very simple question that i'm almost embarrassed to ask. I'm not sure how to order on the X axis in Caravel. It is possible to for instance group by certain names and that works fine. Now however, where trying to group by a certain scale.

You can view the problem here:
screen shot 2016-05-26 at 11 32 25

We now grouped the results in this test based on the scalelevel, which is a integer value.
Is it possible to order those results from zero to eighteen (or any kind or sort)?

Thanks in advance for any kind of help, you guys have been amazing!

request

Most helpful comment

I could do it selecting the option "Sort Bars"

image

All 19 comments

+1 for this and #525, currently I manually create an extremely small 'order by' metric as the 1st metric... but would be nice to be able to specify one

Hi verydxz,

Thanks for the answer, could you maybe give an example of how you implemented this?
When looking at the screenshot further up, you'll see that the X axis actually has important values in there. The 0 > 18 references to the scalelevel in this domain. The Y axis refers to a simple count.

You said that you create a extremely small order by metric as the first metric. If i'd add a small order by in the series, i'd lose the values that I have in the X axis right?

I managed to create the 'order by' metric but had the same issue as @Frituurpanda that I lost the values that I actually wanted to have on the x axis

We're having the same issue, anyone has any updates on this?

At this point i still don't have a good solution to this. Aside from using a small custom metric in the database. That's not a good solution though since you'll have to add that for every usecase manually..

Please, reopen this issue as it is not solved. After #1379, labels are sorted only alphabetically. In case of numeric labels the resulting order is wrong, e.g. 1, 10, 2, 21, 3 instead of 1, 2, 3, 10, 21.

True, have worked around this issue by setting a custom metric in the database to sort based on that. Not really a scaleable solution but it works for my usecase..

I have the same problem.

@Frituurpanda @vera-liu I also have the same problem.

I got the same problem @vera-liu

Still an issue, and with the limitation of running multiple queries (creating temp tables and then selecting from them) being an issue, read: it doesn't work - this is an issue.

I could do it selecting the option "Sort Bars"

image

@iasmini What's the plot you selected?
What release of superset are you using? In Distribution - Bar Chart I can't see any of the fields your screenshot shows!

Thank you :-)

@CriMenghini

Version: {"GIT_SHA": "", "version": "0.17.1"}

image

For me it still does only sort alphabetically.

"version": "0.24.0"

For example: it does not work when ordering months given as strings or numbers.

I think it would be a great improvement to customize the exact column order manually or even change the column labels.

I could do it selecting the option "Sort Bars"

image

This worked for me, thanks!

Screenshot 2019-07-05 at 12 36 04
I don't know if it is still useful or not, but I did it by setting the value of "order_bars" to true, in the "Parameters" of the edit chart part of my "Distribution bar chart" instance.

sorting the chart based on time 00:00 AM ,01:00 AM ,02:00 AM ,03:00AM

if(fd.order_time){
data.forEach((d) => {
d.values.sort(function(a,b){return new Date('1970/01/01 ' + a.x) - new Date('1970/01/01 ' + b.x)});
});
new time chronological order

sorting the chart based on time "January", "February", "March", "April",
var months = ["January", "February", "March", "April", "May", "June","July", "August", "September", "October", "November", "December"];

        data.forEach((d) => { console.log(d.values);
        d.values.sort(function(a, b){ return months.indexOf(a.x) - months.indexOf(b.x); });
        });

Note: we can arrange it in what a custom order we want

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deity-bram picture deity-bram  路  3Comments

thoralf-gutierrez picture thoralf-gutierrez  路  3Comments

dinhhuydh picture dinhhuydh  路  3Comments

ylkjick532428 picture ylkjick532428  路  3Comments

kalimuthu123 picture kalimuthu123  路  3Comments