-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
fix(plugin-chart-echarts): support forced categorical x-axis #26404
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #26404 +/- ##
==========================================
- Coverage 69.15% 66.98% -2.18%
==========================================
Files 1947 1948 +1
Lines 76010 76043 +33
Branches 8481 8493 +12
==========================================
- Hits 52565 50934 -1631
- Misses 21264 22928 +1664
Partials 2181 2181
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
6a0f529
to
ce3ca2a
Compare
1dab26f
to
b60d84e
Compare
badbcc9
to
9bfaf3f
Compare
/testenv up |
@villebro Ephemeral environment spinning up at http://34.220.253.149:8080. Credentials are |
This is amazing! thank you! |
/testenv up |
@villebro Ephemeral environment spinning up at http://34.217.31.67:8080. Credentials are |
xAxisSortSeries === SortSeriesType.Name && typeof sortKey === 'string' | ||
? sortKey.toLowerCase() | ||
xAxisSortSeries === SortSeriesType.Name | ||
? typeof sortKey === 'string' | ||
? sortKey.toLowerCase() | ||
: sortKey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this change, sorting by "category name" wouldn't work if the type is numeric
/testenv up |
@villebro Ephemeral environment spinning up at http://34.216.59.17:8080. Credentials are |
Thank you for the PR @villebro and for nice tests! I noticed that a numerical chart is rendering as categorical when you navigate from the dashboard to Explore. Screen.Recording.2024-01-05.at.09.56.26.movI also noticed it's not possible to drill by when the chart is not categorical. I'm not sure if this is a restriction or if numerical bars could be selected too. Screen.Recording.2024-01-05.at.09.57.54.mov |
@yousoph @Vitor-Avila @sfirke Could you help testing this too? |
Good catch, there must be something in the |
I will test this but out sick this afternoon so probably not until Monday. |
I hope you get well soon! |
/testenv up |
@villebro Ephemeral environment spinning up at http://35.91.107.86:8080. Credentials are |
@michael-s-molina the initial value issue should now be fixed. Please check out my new test dashboard: http://35.91.107.86:8080/superset/dashboard/p/qkWeveYvMXr/ |
@michael-s-molina I believe this is by design - @kgabryje can probably add more context on this. Maybe something we can consider working in the near future? |
@villebro Thanks for tackling the sorting issue. If I didn't forget that the x-axis sorting is using a sorting operator, so the data from backend was sorting ready, I tested this use case in Superset 3.0.2 release, but I can't reproduce it. BTW, theoretically, if we treated a dimension as a categorical, the dimension should be converted to TEXT type in database, but it might be another topic. Screen.Recording.2024-01-06.at.10.25.45.mov |
Got it. Thanks for checking. |
a9e67a7
to
f20e5de
Compare
This reverts commit c615cb5.
Ephemeral environment shutdown and build artifacts deleted. |
@michael-s-molina thanks for tagging me and apologies for the late response. I just tested creating a chart before this fix and tested the upgrade which successfully fixed the chart! Thanks @villebro for working on this change! 🎉 |
(cherry picked from commit 219c4a1)
SUMMARY
This PR adds the option to force a chart with a numerical x-axis to categorical. This makes it possible to sort charts that have a numerical x-axis, while still retaining support for numerical x-axis functionality. This should clear up a compatibility issue between previous versions of Superset, where some versions always treated numerical x-axes as categorical, while others always treated them as numerical.
While working on this, I noticed that the Query based datasource was missing the generic data type information that's needed for charts to operate properly. I believe this should resolve some issues we've seen on charts that are using the SQL Lab query as the source.
Note, that I tried to add similar support for temporal x-axes, but that turned out to be very difficult due to how we handle timestamp formats. Therefore, the force option will only be available when the x-axis is numerical, but not for temporal ones. For use cases where similar sorting is needed for temporal charts, I recommend just casting and formatting them to a string based type first.
AFTER
Now there's a new control that makes it possible to force numerical x-axes to categorical (disabled by default):
Note, that if a sorting value had previously been defined, it will set this control to true by default. This is to ensure that charts that had been created on a previous version of Superset, where the x-axis was numeric but were treated as categorical, will work as they were originally intended.
Here we can see that we're able to sort by the metric value if the chart is forced to categorical style:
BEFORE
Previously the sorting control was visible, but didn't do anything if the x-axis was numeric:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION