Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering on X axis on the distribution bar chart #519

Closed
Frituurpanda opened this issue May 26, 2016 · 24 comments
Closed

Ordering on X axis on the distribution bar chart #519

Frituurpanda opened this issue May 26, 2016 · 24 comments
Labels
enhancement:request Enhancement request submitted by anyone from the community

Comments

@Frituurpanda
Copy link

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!

@georgeke georgeke added the enhancement:request Enhancement request submitted by anyone from the community label Jun 1, 2016
@verydxz
Copy link

verydxz commented Jun 5, 2016

+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

@Frituurpanda
Copy link
Author

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?

@katemarielewis
Copy link

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

@mrbungie
Copy link

mrbungie commented Aug 1, 2016

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

@Frituurpanda
Copy link
Author

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..

@vera-liu vera-liu self-assigned this Oct 3, 2016
@vera-liu vera-liu added this to the Los Cabos Sprint 2016-10-03 milestone Oct 3, 2016
@vera-liu
Copy link
Contributor

#1379

@ondrejkopicka
Copy link

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.

@Frituurpanda
Copy link
Author

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..

@suuuch
Copy link

suuuch commented Jun 21, 2017

I have the same problem.

@Hackeruncle
Copy link

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

@ghost ghost unassigned vera-liu Sep 21, 2017
@harryprince
Copy link

I got the same problem @vera-liu

@vtyr
Copy link

vtyr commented Oct 3, 2017

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.

@vera-liu vera-liu reopened this Oct 3, 2017
@iasmini
Copy link

iasmini commented Jan 26, 2018

I could do it selecting the option "Sort Bars"

image

@CriMenghini
Copy link

@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 :-)

@iasmini
Copy link

iasmini commented Feb 28, 2018

@CriMenghini

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

image

@benkindt
Copy link

benkindt commented Apr 25, 2018

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.

@ariasjose
Copy link

I could do it selecting the option "Sort Bars"

image

This worked for me, thanks!

@rzeAkbari
Copy link

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.

@kalimuthu123
Copy link

kalimuthu123 commented Dec 20, 2019

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

@michalrudko
Copy link

I am facing same issue now with Superset 1.0.1 and Bar Chart (cannot find Distributed Bar Chart any more.
There is no option to Sort Bars in Bar Chart - how to make the bars sorted by x axis label instead of metric value?

@bwgroff
Copy link

bwgroff commented May 12, 2021

So I had a hard time figuring this out too. It's confusing but there are two places that "sort" settings exist in the chart editor. First, in the "Data" view at the bottom. That's not what you want! You want to go to "Customize" and that's where you can find the check box for sort bars. Take a look:
image

zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 17, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 24, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 25, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 26, 2021
@muksah123
Copy link

still after checking sort bar checkbox,it is not sorting bar graph in apache superset

@joaofonsecapromptly
Copy link

Regarding box plot, there is no Sort bars checkbox and when applying sort by, the query still does not work, even with a specific pre made column/metric to sort

@rusackas
Copy link
Member

I think if you open a new issue with a reproducible test case (i.e. using example data and showing the control panel config in question) you'll get a lot more attention on any currently existing issues(s). This thread is 8 years old!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement:request Enhancement request submitted by anyone from the community
Projects
None yet
Development

No branches or pull requests