Skip to content

fix(chart): keep the chart on screen during a dashboard auto-refresh - #45234

Merged
EnxDev merged 19 commits into
apache:masterfrom
EnxDev:feat/chart-keep-visible-on-refresh
Oct 20, 2026
Merged

EnxDev merged 19 commits into
apache:masterfrom
EnxDev:feat/chart-keep-visible-on-refresh

Conversation

@EnxDev

@EnxDev EnxDev commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

On a dashboard with an auto-refresh interval, every chart is replaced by the "No results were returned for this query" empty state for as long as its refresh query is in flight, then comes back when the response lands. With a short interval and slow queries the dashboard spends a good part of its time showing empty states.

Auto-refresh (#37459) suppresses the loading spinner so the chart can stay on screen while it refreshes. ChartRenderer already lets the render through in that case, but it only hands data to SuperChart when the chart status is success or rendered. During the refresh the status is loading, so SuperChart gets queriesData={undefined} with enableNoResults on, and renders the no-results state.

This is a regression from #39459, which converted ChartRenderer to a function component. The class version had a shouldComponentUpdate that returned false while results weren't ready, so the previous frame simply stayed up. The function component re-renders on the status change, so it has to keep passing the data itself.

The fix keeps passing the previous response while an auto-refresh is in flight. The chart reducer leaves queriesResponse untouched on CHART_UPDATE_STARTED, so the response in the store is still the last good one until the new one replaces it. The clone handed to plugins is still memoised on the response identity, so nothing is re-cloned when the status flips to loading.

Nothing changes outside an auto-refresh: a normal load or a manual refresh still shows the spinner, and a finished query with no rows still shows the no-results state.

Related to #34682, which asks for charts to stay visible during a refresh. This restores that for auto-refresh. It doesn't add the spinner overlay for manual refreshes discussed there, so it doesn't close that issue.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before, on a dashboard with a table chart and refresh_frequency: 10, sampling the chart while the /api/v1/chart/data request was delayed by a few seconds:

Refresh state Chart shows
loaded the table
auto-refresh request in flight "No results were returned for this query"
response received the table

Before/after recordings. Same build both times, with and without this change. The dashboard has a table and an ECharts pie with a 10 second refresh interval, and the /api/v1/chart/data requests are delayed by 5 seconds so the in-flight window is easy to see.

Before (master): each chart turns into the no-results state while its refresh request is in flight.

before

After (this PR): both charts stay on screen through the refresh.

after

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- src/components/Chart/ChartRenderer.refresh.test.tsx

The new file doesn't mock SuperChart, because the bug is in what SuperChart does with the data it's given. Two of the four tests fail on master: the chart disappearing when a refresh starts, and a chart mounted in the middle of a refresh.

Manually:

  1. Open a dashboard and set a refresh interval of 10 seconds.
  2. Slow the chart data requests (browser devtools network throttling works).
  3. Watch a chart across a refresh. On master it turns into the no-results state until the request returns. With this change it stays as it was and then updates.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

An auto-refresh suppresses the loading spinner so the chart can stay
visible while its query is in flight. ChartRenderer only handed data to
SuperChart once the chart status was success or rendered, so during the
refresh SuperChart got no data and showed the "No results were returned
for this query" state until the new response landed.

Before the component was converted from a class, shouldComponentUpdate
skipped the re-render while loading and the previous frame stayed up.
The function component re-renders, so it has to keep passing the
previous response, which the store holds until the new one arrives.

Refs apache#34682

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
prevQueriesResponseRef.current = queriesResponse;
}, [queriesResponse]);

const hasAnyErrors = queriesResponse?.some(item => item?.error);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: A two-query chart may have usable first-query data and an errored second query; this rejects it during refresh even though resultsReady previously allowed it.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Incorrect condition logic

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/components/Chart/ChartRenderer.tsx
**Line:** 275:275
**Comment:**
	*Incorrect Condition Logic: A two-query chart may have usable first-query data and an errored second query; this rejects it during refresh even though `resultsReady` previously allowed it.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this state can happen, so I'm leaving the check as it is.

A chart only reaches success or rendered after a 200 from the chart data API, and ChartDataCommand raises ChartDataQueryFailedError as soon as any query in the payload carries an error (superset/commands/chart/data/get_data_command.py). The whole request fails, the chart goes to failed, and the store gets a single-item error response. The one exception is result_type=query, which the View query modal uses and which never feeds the chart. So there's no response where the first query has data and the second has an error, and some(item => item?.error) always agrees with queriesResponse[0].error here.

The check isn't new in this PR either. It came in with #37459 and I only moved it up a few lines so the refresh guard and the clone can share it. If a partial-error response ever did show up, not drawing a chart from it during the refresh is the safer side.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Customized review instruction saved!

Instruction:

In ChartRenderer, do not flag checking for errors across all query responses as overly strict: the chart data API fails the entire request if any query errors, so partial-success responses are not expected.

Applied to:

  • superset-frontend/src/components/Chart/ChartRenderer.tsx

💡 To manage or update this instruction, visit: CodeAnt AI Settings

Comment on lines +276 to +277
const hasValidPreviousData =
(queriesResponse?.length ?? 0) > 0 && !hasAnyErrors;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Self-fetching charts such as deck.gl Multiple Layers have an empty top-level response; this guard returns null during auto-refresh and unmounts their visible chart.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Incorrect condition logic

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/src/components/Chart/ChartRenderer.tsx
**Line:** 276:277
**Comment:**
	*Incorrect Condition Logic: Self-fetching charts such as deck.gl Multiple Layers have an empty top-level response; this guard returns null during auto-refresh and unmounts their visible chart.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 154a252.

For charts with enableNoResults disabled, an array response—including an empty array—counts as a previous response. That lets self-fetching charts keep rendering during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 154a252.

deck.gl Multiple Layers builds an empty queries array, so its response is []. The guard read that as missing previous data and unmounted the map on every refresh tick, and the map then loaded all of its layers again when the query came back. The guard has behaved this way since #37459, but it's the same symptom this PR is about, so the fix belongs here.

Charts whose metadata sets enableNoResults: false now count any response that landed as previous data. Every other chart still needs a non-empty response, so a regular chart can't fall back to the no-results state in the middle of a refresh.

ChartRenderer.refresh.test.tsx covers it with a chart that issues no query: it has to stay mounted through loading and success without remounting. Two more tests pin the cases that must still render nothing: a self-fetching chart whose first query hasn't returned, and a regular chart with an empty response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 2c0abed.

For charts with enableNoResults disabled, an array response—including an empty array—counts as a previous response. That lets self-fetching charts keep rendering during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of e630ebf.

For charts with enableNoResults disabled, an array response—including an empty array—counts as a previous response. That lets self-fetching charts keep rendering during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of b4c59e9.

For charts with enableNoResults disabled, an array response counts as a previous response even when it is empty. This lets self-fetching charts retain renderable results during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 7b9f12e.

For charts with enableNoResults disabled, an array response counts as a previous response even when it is empty. This lets self-fetching charts retain renderable results during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 344470b.

For charts with enableNoResults disabled, an array response counts as a previous response even when it is empty. This lets self-fetching charts retain renderable results during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of e987f4b.

For charts with enableNoResults disabled, an array response counts as a previous response even when it is empty. This lets self-fetching charts retain renderable results during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 0eb20b5.

For charts with enableNoResults disabled, an array response counts as a previous response even when it is empty. This lets self-fetching charts retain renderable results during auto-refresh.

If that's not right, unresolve this thread and CodeAnt will leave it open.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; no credible unresolved blocker is evident in the current code or review discussions.
  • Added tests cover keeping charts mounted during refresh, reloading self-fetching layers, and updating data-driven map views while preserving custom viewports.

Assessed commit: 0eb20b5bd5e1

The existing auto-refresh test only checked that SuperChart rendered, so
it passed while the chart was being handed no data. It now asserts on
the data too. Also covers the manual refresh case, where ChartRenderer
renders nothing and the spinner shows alone.

Refs apache#34682

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.13793% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.75%. Comparing base (3988a77) to head (e987f4b).
⚠️ Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
...nd/plugins/preset-chart-deckgl/src/Multi/Multi.tsx 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #45234      +/-   ##
==========================================
+ Coverage   83.65%   83.75%   +0.10%     
==========================================
  Files        3053     3054       +1     
  Lines      200651   200750      +99     
  Branches    46825    46871      +46     
==========================================
+ Hits       167856   168147     +291     
+ Misses      29554    29362     -192     
  Partials     3241     3241              
Flag Coverage Δ
javascript 79.59% <99.13%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

EnxDev and others added 3 commits October 13, 2026 09:18
deck.gl Multiple Layers issues no query of its own, so its response is
an empty array. The loading guard read that as missing previous data and
unmounted the map on every refresh tick, which made it load all of its
layers again.

Charts whose metadata sets enableNoResults to false count any response
that landed as previous data, so they stay on screen while the refresh
query is in flight. Other charts still need a non-empty response.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@EnxDev
EnxDev requested a review from aminghadersohi October 13, 2026 19:09
EnxDev and others added 2 commits October 13, 2026 22:08
SuperChart loads the chart plugin asynchronously, so the two tests that
check a chart is not rendered were asserting before it could have
appeared. The self-fetching one passed even with the loading guard
removed.

Both now wait for the load to settle, and the self-fetching test also
checks that the chart never mounted.

Refs apache#34682

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at 438df88. The :285 Major doesn't apply: get_data_command.py:59-66 fails the whole request on any query error, and the error gate is net-zero vs master. All 4 guards die under mutation, control green. The 3 merges match clean merge-trees. CI 66 legs, 0 failures.

A failed load leaves its errored response in the store, and the next
CHART_UPDATE_STARTED clears chartAlert but not queriesResponse. The
hasAnyErrors check is what keeps that response from being drawn as chart
data while the retry is in flight. The comment names that route so the
check does not read as dead code.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@EnxDev
EnxDev requested a review from aminghadersohi October 13, 2026 21:42
@EnxDev
EnxDev requested a review from sadpandajoe October 15, 2026 10:03
ChartRenderer keeps deck.gl Multiple Layers mounted through an auto-refresh,
so the remount that used to reload its self-fetched layers no longer happens
and the map kept showing the first-loaded data. The chart now gets
isRefreshing through its own transformProps and reloads its layers when a
refresh lands, keeping the current layers and viewport on screen until each
replacement arrives.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
EnxDev and others added 3 commits October 15, 2026 14:13
… chart

The plugin reports render success only once, after it loads, so a chart
kept on screen through an auto-refresh stayed at success and dropped out
of the rendered set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Standalone v1 payloads carry no form_data, so categories were only built
on mount and features of a category that first appeared on refresh were
filtered out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@EnxDev
EnxDev requested a review from sadpandajoe October 15, 2026 13:08
The chart stays mounted through an auto-refresh, so the viewport is no
longer recomputed by a remount. The containers only refit when
payload.form_data changes, and the v1 payload is the query response,
which carries no form_data, so an autozoom map stayed fitted to the
first-loaded rows.

CategoricalDeckGLContainer (Scatterplot, Arc, Path), Polygon and the
createDeckGLComponent factory (Grid, Hex, Heatmap, Contour, Screengrid)
now refit when autozoom is on and the features change. DeckGLContainer
only moves the map when the viewport prop changes by value, so a
refresh whose rows fit the same bounds leaves the viewer's pan alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 0eb20b5
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ad7c4aac4794dbeffd75bb4
😎 Deploy Preview https://deploy-preview-45234--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

…esh lands

Both maps fitted to the data only at mount and relied on the remount
during a dashboard refresh to fit the new rows. With the chart kept on
screen they stayed framed on the first-loaded area.

Point Cluster Map: computeFitBounds now reads the current bounds, and
an effect refits when the bounds change by value. Viewport overrides
still take precedence, and a refresh with the same bounds keeps the
viewer's pan.

Cartodiagram: in FIT_DATA mode the map refits when the chart configs
change. currentChartConfigs is deep-compared, so a refresh with the
same data, or a zoom that only re-runs transformProps, does not refit.
A CUSTOM map view keeps its fixed center.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every v1 transform builds a new features array, including the run Explore
triggers when it writes the viewer's viewport back through
setControlValue. Keying the autozoom refit on that array's identity
snapped the map back to the fitted view after a tilt or rotate. The
refit now compares the bounds of the points by value, so it still runs
when an auto-refresh brings rows in another place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@rusackas rusackas left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the deck.gl Multiple Layers unmount-on-refresh bug, and nice rebuttal on CodeAnt's partial-error-response flag too. Traced it back to get_data_command.py myself and the request really does fail wholesale on any query error, so that one's noise. Tests look thorough for how much surface this touches. LGTM, agreeing with sadpandajoe's approval here.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 20, 2026
# Conflicts:
#	superset-frontend/plugins/preset-chart-deckgl/src/CategoricalDeckGLContainer.test.tsx
@EnxDev
EnxDev merged commit 2518658 into apache:master Oct 20, 2026
76 checks passed
rusackas added a commit that referenced this pull request Oct 21, 2026
Resolve deck.gl Multi index.ts: keep this PR's custom_thumb_* image
imports (byte-identical renames of master's images) and take master's
Multi-local transformProps import from #45234.

Co-Authored-By: Evan Rusackas <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins requires:rebase Requires rebasing on top of current master risk:chart-metadata size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants