metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.77k stars 5.15k forks source link

Changing sorting does not apply for X-axis anymore #27279

Closed flamber closed 1 year ago

flamber commented 1 year ago

Describe the bug Changing sorting does not apply for X-axis anymore, which has been a workaround to override the automatic ordering. Regression since 0.45.0

To Reproduce

  1. Native > Sample:
    select -3 o, 'F2021' k, 1 v
    union all select -2, 'V2021', 2
    union all select -1, 'S2022', 3
    union all select 0, 'F2022', 4
  2. Save question - click "Explore results"
  3. Go to Notebook editor, so we can define the sorting like so: image
  4. Change visualization to Bar and stacked (just makes it easier to see the problem) image

Expected behavior 0.44.6 image

Information about your Metabase Installation: Tested 0.44.6 thru 0.45.1

npfitz commented 1 year ago

Spent some time looking into this. This is happening because the graph.series_order forces the order of the series in LineAreaBarChart. Because it's a single array, we may also need to sort the order of the rows in the individual series.data.rows response. However, the relationship between series_order and breakouts seems like it might be a complicated one. To me the more important part of this is that you have no way to order K anymore, not O. We may need to come up with some rules like not being able to sort on a second dimension in order for it to make much sense.

csauge commented 1 year ago

Hi I have the same issue, Something is broken concerning the sort of the x-axis for stacked chart between v0.44.6 and v0.45.1. See my comment here: https://discourse.metabase.com/t/latest-update-breaks-x-axis-sorting/23135/3

cdeweyx commented 1 year ago

@npfitz I suspect you already saw this post but that helped make things more clear for me. It seems like it may require some refactoring, but I wonder if it's feasible for us to get to a place where we:

  1. Respect sorting first and foremost
  2. Any drag-and-drop reordering in settings overrides the initial order prescribed through sorting

I feel like ordering the x-axis series should ideally be independent of the new functionality where you can choose how to order breakouts, right? Or maybe I'm missing something more nuanced here.

npfitz commented 1 year ago

I actually think I have a fix for this coming today. When ordering the series we are removing the _raw prop from what gets passed around. This has caused a couple issues (also fixes #27063 ). Making some tests now.