Bug description

Environment

  • Superset version: v6.x
  • Upgrade path: imported charts from v4 → v6
  • Database: ClickHouse
  • Chart type: Line chart

Description

When using a string dimension for the x‑axis (e.g. LEFT(toString(day_id), 6)), the line chart connects non‑adjacent categories even though intermediate categories exist in the dataset.

With a numeric dimension (toInt32(LEFT(...))), the chart renders correctly and includes all intermediate points.


Steps to Reproduce

  1. Run the following query in SQL Lab:
-- INT version
SELECT
  toInt32(LEFT(toString(day_id), 6)) AS month_id,
  sum(value) AS total_value
FROM (
  SELECT
    toInt32(formatDateTime(d, '%Y%m%d')) AS day_id,
    toDayOfYear(d) AS value
  FROM (
    SELECT addDays(toDate('2024-01-01'), number) AS d
    FROM numbers(366) -- leap year
  )
  WHERE d < toDate('2024-05-15') OR d > toDate('2024-08-10')
)
GROUP BY month_id
ORDER BY month_id;
-- STRING version
SELECT
  LEFT(toString(day_id), 6) AS month_id,
  sum(value) AS total_value
FROM (
  SELECT
    toInt32(formatDateTime(d, '%Y%m%d')) AS day_id,
    toDayOfYear(d) AS value
  FROM (
    SELECT addDays(toDate('2024-01-01'), number) AS d
    FROM numbers(366)
  )
  WHERE d < toDate('2024-05-15') OR d > toDate('2024-08-10')
)
GROUP BY month_id
ORDER BY month_id;
  1. Both queries return the following aggregated dataset:
month_id SUM(value)
202401 496
202402 1334
202403 2356
202404 3195
202405 1799
202408 4914
202409 7785
202410 8990
202411 9615
202412 10881
  1. Create two line charts:
    • Chart A: x‑axis = month_id (INT)
    • Chart B: x‑axis = month_id (STRING)

Expected Behavior

Both charts should render a line through all categories present in the dataset, including 202408.


Actual Behavior

  • INT chart: renders correctly → line goes 202405 → 202408 → 202409.
  • STRING chart: skips 202408 and draws a line directly from 202405 → 202409, even though 202408 exists in the dataset.

Notes

  • This behavior changed between Superset v4 and v6.
  • In v4, both INT and STRING behaved the same.
  • In v6, categorical (string) axes appear stricter, but this results in valid categories being skipped in line charts.

Image

Query to reproduce Virtual Dataset:

SELECT
    toInt32(formatDateTime(d, '%Y%m%d')) AS day_id,
    toDayOfYear(d) AS value
FROM (
    SELECT addDays(toDate('2024-01-01'), number) AS d
    FROM numbers(366)  -- 2024 is a leap year
) 
WHERE d < toDate('2024-05-15')
   OR d > toDate('2024-08-10')
ORDER BY day_id

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.11

Node version

18 or greater

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]

This is a known change in Superset v6.x: the ECharts plugin introduced stricter handling for categorical (string) x-axes in line charts, which can cause intermediate categories to be skipped even if they exist in your dataset. This differs from earlier versions, where both numeric and string x-axes behaved the same. The new logic treats string axes as true categorical axes, and the rendering pipeline may skip categories if the axis or series extraction logic doesn't recognize all present categories as valid ticks, especially if the axis is not explicitly set to categorical or if the chart's configuration doesn't match the data type "ECharts plugin changelog".

There is a "Force categorical" option in the chart controls that can help ensure the x-axis is treated as categorical, which may resolve the issue of skipped categories. This option is typically found under the x-axis or general chart settings. If you don't see it, it may be due to the current chart configuration or the specific data type of your x-axis column "Force categorical" control discussion.

If enabling "Force categorical" does not resolve the issue, a common workaround is to ensure your dataset is pre-sorted and that all expected categories are present in the data returned to the chart. In some cases, creating a calculated field that encodes the desired sort order or category sequence can help "Sorting and categorical axis workarounds".

This change is intentional and part of a broader move toward more explicit and configurable axis handling in Superset v6.x line charts.

To reply, just mention @dosu.


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

Comment From: DataStrategistTeam

Applying 'Sort Series by Category Name' has no effect on the output.

Image

Comment From: rusackas

Did the "Force Categorical" checkbox under the "Data" tab make any difference as the bot suggested?

Comment From: DataStrategistTeam

@rusackas there is no Force Categorical checkbox under Data tab; no difference even when setting Sort Series By Category name under Customize tab

Image

Comment From: YousufFFFF

Hi, I’d like to work on this issue.
If it’s still available, could you please assign it to me?
I’ve already started reviewing the code path for categorical X-axes in ECharts. @rusackas

Comment From: sfirke

Assigned to you, @YousufFFFF !

Comment From: YousufFFFF

Thanks! I’ll start working on this and will open a draft PR soon.