Bug description

Description:

When switching between different chart types in Superset, duplicate measures are added unexpectedly. This issue occurs specifically when switching between a Line Chart and a Waterfall Chart.

Steps to reproduce:

  1. Create a Line Chart and set up the X-Axis and a Measure (e.g., SUM(goods_services_export)).
    Image

  2. Change the chart type to Waterfall Chart. The selected measure is sometimes removed.
    Image

  3. Re-add the same measure (SUM(goods_services_export)) and build the chart successfully.
    Image

  4. Switch the chart type back to Line Chart. Now, the measure appears twice in the settings. Image

  5. If you continue switching between chart types (Line Chart → Waterfall Chart → Line Chart), new duplicate measures keep appearing. Image

Expected behavior:

Switching between chart types should not result in duplicate measures. The selected measures should persist without being reset or duplicated.

Actual behavior:

  • Measures are removed when switching to a Waterfall Chart.
  • When switching back to a Line Chart, the measure is duplicated.
  • Repeating the switch process keeps adding more duplicates.

Environment:

  • Database backend: ClickHouse

Possible Cause:

It seems like the UI is not correctly handling measure persistence when switching chart types. Measures might not be properly reset or are being re-added instead of being retained.

Additional context:

This issue happens inconsistently, but once it starts, it continues with every switch between chart types.

Screenshots/recordings

No response

Superset version

4.1.1

Python version

I don't know

Node version

I don't know

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.
  • [ ] 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]

The issue you're experiencing with duplicate measures appearing when switching between chart types in Superset seems to be related to how the frontend handles measure persistence. Unfortunately, I couldn't find specific information in the repository about how Superset manages state for chart configurations or any known issues related to this behavior in version 4.1.1.

However, Superset's frontend differentiates between chart types using plugins configured with unique keys for each visualization type. Each plugin is responsible for the specific configuration and rendering logic of its associated chart type [1]. This might be where the issue arises, as the state management for measures might not be correctly handled when switching between incompatible chart types like Line Chart and Waterfall Chart.

To address this issue, you might want to investigate the frontend code responsible for managing chart configurations and see if there are any discrepancies in how measures are reset or duplicated when switching chart types. Additionally, checking for any recent updates or patches in the Superset repository that might address this issue could be helpful.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Comment From: hainenber

I can confirm this is reproducible in latest master branch.

Comment From: rusackas

This is indeed still happening.

Comment From: LisaHusband

This bug is not just happening between the waterfall chart and the line chart, but between the waterfall chart and almost every other chart. The logic implementation of this waterfall chart is definitely problematic, it's like a virus, it's so fascinating. 😄

Comment From: msyavuz

When going back from waterfall to line chart, should line chart have one metric coming from waterfall or should it keep previous metrics as well? @rusackas https://github.com/user-attachments/assets/89b113e6-f1f1-4682-8254-49651eb7edfb

Comment From: LisaHusband

However, after conducting a test, I found that this issue shouldn't be considered a problem. This is because the first metric attribute of the line chart is passed in as the metric for the waterfall chart, and the waterfall chart then modifies this metric. The change in the waterfall chart affects the first metric of the line chart. As for the duplicate values shown in the test video, this happens because the modified metric in the waterfall chart happens to be the same as the second metric of the line chart. Therefore, when the change in the waterfall chart is mapped to the line chart, it results in the duplication of the metric as described in the issue.

Comment From: LisaHusband

Test Video already upload to google drive, and shared by this link

Comment From: LisaHusband

When the metric in the waterfall chart differs from the metrics used in the line chart, no duplication or increase occurs. Generally speaking, when switching between the waterfall chart and the line chart, metric changes will only focus on the first metric — this happens after applying the changes in my PR. And I believe it should be this way, because we only pass the first metric to the waterfall chart (as it is restricted to accept only one metric). Given the current design philosophy — where metric and other form data are globally shared — I believe this is the best approach.