Annotation cannot be updated synchronously with filter changes. #44408
Replies: 6 comments
|
Hi @Vance-Chen! I'm Dosu and I’m helping the superset team. This is a known limitation in Superset: event annotation layers on line charts do not always update in sync with filter changes. The main chart updates, but the annotation lines can remain stale until you manually refresh the chart or dashboard. This behavior is confirmed by other users and tracked in issues like #9842. Technically, annotation queries are supposed to re-run with the latest filters when a chart refreshes, but because annotation fetching and chart data fetching are handled as separate asynchronous requests, they can get out of sync—especially if there are delays or state desynchronization. Recent improvements (see PR #34383 and PR #34709) have made annotation synchronization more robust, but there is still no built-in guarantee that annotations will always update perfectly with every filter change. Workarounds include: manually refreshing the chart, or (if possible) including the annotation logic in your main chart query so that everything updates together. Also, check your cache settings, as aggressive caching can sometimes cause stale annotation data to persist. For now, minimizing reliance on dynamic annotation tables for critical visual cues is recommended until further improvements land. You can follow ongoing improvements in the Superset changelog and GitHub for future updates to annotation synchronization. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
|
Hi Dosu, thank you for you reply.
|
|
There isn’t a built-in way in Superset to include annotation logic directly in the main chart query, but you can achieve synchronous updates by merging your annotation/event data with your main chart data in a single SQL query. For example, you can use a SELECT
date,
value,
'main' AS series_type
FROM main_table
WHERE {{ filter_condition }}
UNION ALL
SELECT
event_date AS date,
NULL AS value,
'event' AS series_type
FROM annotation_table
WHERE {{ filter_condition }}Then, in Superset, plot both series on the same line chart (or Mixed Chart) using the This approach works best for time series and line charts that support multiple series. You may need to adjust your chart configuration to display the annotation series as markers or lines, and style them differently for clarity. Be aware that this method can increase query complexity and may not be ideal for very large datasets or all chart types. There’s no official example in the Superset docs, but this pattern is a common workaround and is discussed in community threads as a way to keep reference lines or events in sync with chart data [source]. The Superset codebase also shows that annotation data is often merged into the main chart data array before rendering, which is similar in spirit to this approach [source]. Let me know if you want a more detailed SQL example or help configuring the chart! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
|
Agreed passing filters through to Annotations may make sense in some cases, but not others. The Jinja templating is indeed one way, but honestly, that Annotations feature is in need of a revamp, and "filter controls" should be part of that discussion. |
|
This is intentional — #10115 explicitly excludes dashboard filters from annotation queries. Leaving this open since Annotations could use a revamp anyway. |
|
moving this to discussions in case if we want to revamp annotations. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Bug description
I have a line chart, and add a event annotation to it , the event annotation is a table which change follow the filter changing, but when i change the filter, line chart update, but the annotation in char still older, i need refresh the chart by manual. how to fix it ?
I guess when apply the new filter, the line chart updates, the table which add as a event annotation also updates, but it doesn't render to the line chart.
Screenshots/recordings
No response
Superset version
Version: 4.1.1
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
All reactions