You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Re-initialize metric charts when instrument unit, type or monotonicity changes - #21143
ChartBase decides between a full chart initialization and a data update using the instrument key (meter and instrument names), the dimension attributes, the theme and the display options. Switching resources can show an instrument with the same key and dimensions but a different unit, type or monotonicity. The chart then called updateChart, which keeps the previous instrument's trace names and layout, so the legend labels could be wrong.
Trace names come from the unit, and from whether the instrument is a monotonic counter ("per interval"). The type decides which traces are drawn. This PR adds all three to the re-initialization check.
Comparing dimension attributes by value, which stops charts re-initializing on every refresh, reached main through #21412. That removed the re-initialization that previously covered this case. This PR originally carried that value comparison too; only this follow-up remains after rebasing onto main.
Testing
New test PlotlyChartTests.UpdateDataAsync_SameInstrumentKeyWithDifferentUnitTypeOrMonotonicity_ReinitializesChart covers a unit change, a type change and a monotonicity change. All three cases fail without the ChartBase change.
All non-quarantined, non-outerloop tests in Aspire.Dashboard.Components.Tests pass.
Sébastien Ros (sebastienros)
changed the title
Stop re-initializing metric charts on every data refresh
Stop re-initializing metric charts on every data refresh (legacy dashboard backport)
Nov 2, 2026
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the chart refresh flow, resource switching, and regression coverage. I found one case where switching resources can leave the chart using the previous instrument’s labels or trace layout.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Explicit duration or selection changes can be discarded by the tick throttle, leaving read-only metric tables indefinitely stale without a periodic retry.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Throttle drops explicit duration updates for read-only tables
Value-equal dimensions now send explicit duration or selection refreshes through the tick throttle, which can discard the only update. For example, changing a read-only metric table's duration within its one-second UpdateInterval can leave the previous rows displayed indefinitely because read-only repositories have no periodic tick to retry it. Make explicit data/window changes bypass the throttle or schedule a trailing data update without reinitializing Plotly, and add a read-only regression test for a duration change inside the throttle interval.
…y changes
The instrument key only contains the meter and instrument names. Switching
resources can show an instrument with the same key and dimensions but a
different unit, type or monotonicity. Each of these changes the rendered
trace names or layout, which only a full initialization replaces.
Comparing dimension attributes by value removed the re-initialization that
previously covered this case.
Sébastien Ros (sebastienros)
changed the title
Stop re-initializing metric charts on every data refresh (legacy dashboard backport)
Re-initialize metric charts when instrument unit, type or monotonicity changes
Nov 4, 2026
docs_optional → bug_fix_restores_documented_behavior. No signals triggered (signal_count 0). Changed files: src/Aspire.Dashboard/Components/Controls/Chart/ChartBase.cs and tests/Aspire.Dashboard.Components.Tests/Controls/PlotlyChartTests.cs. The change fixes chart re-initialization so legend labels are correct when the instrument unit, type or monotonicity changes. There are no new options, strings, or public surface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ChartBasedecides between a full chart initialization and a data update using the instrument key (meter and instrument names), the dimension attributes, the theme and the display options. Switching resources can show an instrument with the same key and dimensions but a different unit, type or monotonicity. The chart then calledupdateChart, which keeps the previous instrument's trace names and layout, so the legend labels could be wrong.Trace names come from the unit, and from whether the instrument is a monotonic counter ("per interval"). The type decides which traces are drawn. This PR adds all three to the re-initialization check.
Comparing dimension attributes by value, which stops charts re-initializing on every refresh, reached main through #21412. That removed the re-initialization that previously covered this case. This PR originally carried that value comparison too; only this follow-up remains after rebasing onto main.
Testing
PlotlyChartTests.UpdateDataAsync_SameInstrumentKeyWithDifferentUnitTypeOrMonotonicity_ReinitializesChartcovers a unit change, a type change and a monotonicity change. All three cases fail without theChartBasechange.Aspire.Dashboard.Components.Testspass.