Bug description

In this scenario, the x-axis is set to the version field (of type varchar), and I want to sort the x-axis based on another field prod_dt. However, I couldn't find where to configure this — it seems to be restricted to sorting only by the version field itself. Image

Screenshots/recordings

No response

Superset version

5.0.0

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

Hi @plus-zhang! I'm Dosu and I’m helping the superset team.

In Superset 5.0.0, sorting a line chart's categorical x-axis (like a varchar "version" field) by a different field (such as "prod_dt") is not supported out of the box. The "Force Categorical" option only appears for numeric columns, not varchar fields, and the x-axis sort controls only allow sorting by the x-axis field itself or relevant metrics—not by an unrelated field like "prod_dt" reference reference.

A common workaround is to pre-sort your dataset or create a calculated field in your source query or dataset that encodes the desired sort order, then use that as your x-axis. Alternatively, some chart types (like Bar Chart) have more flexible sorting options reference.

If you need this feature in line charts, it would require a new control and deeper changes to Superset's data model and query generator.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

Comment From: rusackas

What I'm not sure of here is why your column is of an unknown type. The ? is unusual for a varchar column, where I'd expect to see str like in this screenshot, where the Sort Axis controls DO appear.

Image

If you open the dataset editor modal, does that column have "is dimension" checked? Not sure if that makes a difference here.

Comment From: plus-zhang

What I'm not sure of here is why your column is of an unknown type. The ? is unusual for a varchar column, where I'd expect to see str like in this screenshot, where the Sort Axis controls DO appear.

If you open the dataset editor modal, does that column have "is dimension" checked? Not sure if that makes a difference here.

Image Yes, I have enabled "is dimension", and the tooltip when I hover the field shows "var_string"