Skip to content

Microsoft chart control fidelity: gridlines, clipping, culture, Y axis title, label backgrounds, legend layout (fixes #77) - #78

Merged
davidnmbond merged 2 commits into
mainfrom
feature/MS-26667-renderer-fidelity
Oct 1, 2026
Merged

davidnmbond merged 2 commits into
mainfrom
feature/MS-26667-renderer-fidelity

Conversation

@davidnmbond

Copy link
Copy Markdown
Contributor

Fixes #77. Found by the Magic Suite ChartMagic vs DocMagic comparison (Jira epic MS-26667); each item is a setting that drew differently from the Microsoft chart control, or could not be expressed so Magic Suite refused the whole chart.

See the commit message for the full list. In short:

  • Gridlines: an interval of their own, dash styles, a separate minor width.
  • Plot: series clipped to the inner plot; ticks counted from an explicit minimum (IntervalStartsAtMinimum); IsMarginVisible on the category axis.
  • Numbers: Chart.Culture for axis and data labels.
  • Y axis title: shrunk to fit beside the labels instead of drawn over them.
  • Data labels: Series.LabelBackColor.
  • Legends: Table style, LegendItemOrder (stacked series listed from the top), TextWrapThreshold (25 by default), row wrapping, short columns kept a line apart, labels kept on the image, and pie legends honouring the style.

Version 9.2. New public API, and three defaults change existing output: stacked charts list their legend in reverse, legend text over 25 characters wraps, and series are clipped to the plot. Each matches the Microsoft chart control.

Tests: 136 pass (121 existing, of which three were updated: two marker tests now ignore the plot clip in <defs>, and the overlap test allows a wrapped row; plus 15 new in RendererFidelityTests and 8 new legend tests).

Do not merge yet: being verified against the Magic Suite integration first.

🤖 Generated with Claude Code

…rt control does (fixes #77)

Found by the Magic Suite renderer comparison (MS-26667).

Axes and plot:
- MajorGridInterval spaces major gridlines independently of the labels.
- Gridline dash styles, and a minor gridline width of its own.
- AxisArea.IntervalStartsAtMinimum counts ticks from an explicit minimum.
- AxisArea.IsMarginVisible lets the categories run from end to end.
- Series are clipped to the inner plot.
- The Y axis title is shrunk to fit beside the tick labels, or left out.
- Chart.Culture formats axis and data labels (C2, P0, decimals).
- Series.LabelBackColor fills behind data labels.

Legends:
- Table style, laid out in as many columns as the height needs.
- LegendItemOrder, Auto listing stacked series from the top of the stack.
- TextWrapThreshold, 25 characters by default.
- A row wraps instead of running off the legend; a short column keeps
  entries a line apart; a label too wide for the image gives up the inset,
  then is shortened with an ellipsis.
- Pie and funnel legends honour the style.

Text is measured with the embedded face for all of this.

Version 9.2: new public API, and the legend order, text wrapping and
plot clipping defaults change existing output.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 medium · 1 minor

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
BestPractice 1 minor
Complexity 2 medium

View in Codacy

🟢 Metrics 91 complexity · 2 duplication

Metric Results
Complexity 91
Duplication 2

View in Codacy

🟢 Coverage 88.97% diff coverage · +1.21% coverage variation

Metric Results
Coverage variation ✅ +1.21% coverage variation
Diff coverage ✅ 88.97% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (4fe8f47) 3553 2909 81.87%
Head commit (7cb6e56) 3825 (+272) 3178 (+269) 83.08% (+1.21%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#78) 417 371 88.97%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

…o its width (#77)

- The outer border is drawn after the legend and annotations, so the
  legend's box no longer covers it, and inset by half its width so none of
  it falls off the image. Any other stroked element is inset the same way.
- Dash patterns are the GDI+ ones in units of the line width, as the
  Microsoft chart control draws them, and dashed strokes use butt caps:
  round caps closed the gaps, so a thick dashed line read as solid. Dot was
  drawn as a dash.
- A legend label gives up its inset against the image edge as well as the
  legend's, so "Manchester" fits a 144 pixel legend unshortened.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@davidnmbond
davidnmbond merged commit 3bc38e3 into main Oct 1, 2026
7 of 8 checks passed
@davidnmbond
davidnmbond deleted the feature/MS-26667-renderer-fidelity branch October 1, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft chart control fidelity: gridlines, clipping, margins, culture, Y axis title, label backgrounds and legend layout

1 participant