Repository navigation
fix(chart): keep the chart on screen during a dashboard auto-refresh - #45234
Conversation
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); |
There was a problem hiding this comment.
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
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 fixThere was a problem hiding this comment.
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.
There was a problem hiding this comment.
✅ 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
| const hasValidPreviousData = | ||
| (queriesResponse?.length ?? 0) > 0 && !hasAnyErrors; |
There was a problem hiding this comment.
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
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 fixThere was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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.
There was a problem hiding this comment.
✅ 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 PR Risk: Low Risk
Assessed commit: |
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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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]>
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
left a comment
There was a problem hiding this comment.
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]>
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]>
… 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
✅ Deploy Preview for superset-docs-preview ready!
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]>
…ible-on-refresh-ci
There was a problem hiding this comment.
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.
# Conflicts: # superset-frontend/plugins/preset-chart-deckgl/src/CategoricalDeckGLContainer.test.tsx
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]>
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.
ChartRendereralready lets the render through in that case, but it only hands data toSuperChartwhen the chart status issuccessorrendered. During the refresh the status isloading, soSuperChartgetsqueriesData={undefined}withenableNoResultson, and renders the no-results state.This is a regression from #39459, which converted
ChartRendererto a function component. The class version had ashouldComponentUpdatethat returnedfalsewhile 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
queriesResponseuntouched onCHART_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 toloading.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/datarequest was delayed by a few seconds: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/datarequests 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.
After (this PR): both charts stay on screen through the refresh.
TESTING INSTRUCTIONS
The new file doesn't mock
SuperChart, because the bug is in whatSuperChartdoes 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:
ADDITIONAL INFORMATION
🤖 Generated with Claude Code