#13606·MudBlazor

Nested overlay chart bars are misaligned when the host has MatchBoundsToSize

Author: JorrenSchepersCreated Aug 9, 2026Updated Sep 28, 2026
Labelsbug

Before reporting

  • I searched existing issues
  • I tried in private/incognito browser

What went wrong?

Description

When a nested overlay renders, its bars are shifted horizontally relative to the host chart. The offset grows with the width of the host's Y-axis tick labels: it's negligible with 1–3 character labels and becomes clearly visible once the widest label is ~4+ characters (values ≥ 1000, e.g. 1000, 2500). The overlay is shifted left and drawn slightly wider; the offset is largest at the left edge and converges to ~0 at the right edge.

Discovered with MudBlazor v9.6.0, still present in v9.8.0.

Expected behavior

The overlay shares the host's exact plot area (same left/right margins), so the two sets of bars line up.

Actual behavior

The overlay's plot area starts further left than the host's, so the bars don't align.

Possible root cause (copilot suggestion, claude opus 4.8)

SharedData (AxisGridData) shares the Y-scale and bound width/height but not the horizontal plot margins. Each chart computes its own left margin:

csharp
HorizontalStartSpace = max(10 + ceil(YAxisLabelSize.Width), 30)

The host measures its Y-axis tick labels (e.g. "2500" ≈ 28px → left margin ≈ 39px). The overlay draws no Y-axis labels of its own, so its YAxisLabelSize is null → it uses the 30px minimum. Both charts share the same right edge (BoundWidth − HorizontalEndSpace), so the overlay's plot area is ~9px wider on the left → bars drift left, worst at the left group, ~0 at the right. Bar width differs slightly too, because the different horizontalSpace yields a different tickWidth and hence _barWidth.

Measured example (v9.6.0, labels 500–2500): host left margin 39px vs overlay 30px → ~9px shift on the first group, tapering to ~0 on the last; bar stroke-width 9.56 (host) vs 9.70 (overlay).

Possible fix (copilot suggestion, claude opus 4.8)

Include the host's HorizontalStartSpace/HorizontalEndSpace (or the full plot-area rectangle) in AxisGridData/SharedData so the overlay uses the host's horizontal margins instead of recomputing them from its own (absent) Y-axis labels.

Reproduction link

https://try.mudblazor.com/snippet/QOcgkCYZTGgZGBDb

Reproduction steps

  1. Run the code in the reproduction link. Strange enough, for me it does not compile in the playground. Error: The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'ChartSeries<T>' Locally I don't have that problem, afaik int is a non-nullable value type.

Version (bug)

v9.6.0

Version (working)

No response

Environment

Chrome

Blazor rendering mode

Server