Add first-class PowerPoint bubble charts#2179
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73d4b26047
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4665a48e72
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6da4f7acac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a11c1d98f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| + plotArea.Elements<C.AreaChart>().Count() | ||
| + plotArea.Elements<C.RadarChart>().Count() | ||
| + plotArea.Elements<C.ScatterChart>().Count() | ||
| + plotArea.Elements<C.BubbleChart>().Count() |
There was a problem hiding this comment.
Reject mixed snapshots that omit bubble layers
When a native plot area contains a bubble layer plus at least two other compatible layers, this count sends it through TryCreateMixedChartSnapshot, but that method has no C.BubbleChart branch. The two other layers can therefore make parts.Count > 1 and produce a successful snapshot that silently excludes every bubble, causing shared image, HTML, and PDF exports to omit source data; explicitly reject such mixed plots or include the bubble layer in the mixed snapshot.
Useful? React with 👍 / 👎.
| if (series.BubbleSizes != null && i < series.BubbleSizes.Count) { | ||
| body.Append(" data-officeimo-bubble-size=\"") | ||
| .Append(OfficeHtmlText.EscapeAttribute(series.BubbleSizes[i].ToString("G17", CultureInfo.InvariantCulture))) | ||
| .Append('"'); |
There was a problem hiding this comment.
Preserve bubble sizing semantics in semantic HTML
For a bubble chart whose native BubbleScale is not 100 or whose SizeRepresents is Width, semantic export records only the raw per-point sizes here. On import, TryCreateBubbleChartData recreates the chart through CreateSharedBubbleChart, which always uses scale 100 and Area, so an export/import round trip materially changes bubble dimensions and proportions without an approximation diagnostic; serialize and restore both chart-level settings alongside the size values.
Useful? React with 👍 / 👎.
| markerOutlineColor: item.StrokeColor ?? item.Color, | ||
| markerOutlineWidth: item.StrokeWidth)); |
There was a problem hiding this comment.
Preserve explicitly disabled bubble outlines
When an imported bubble series explicitly uses <a:noFill/> for its outline, ReadSeriesStrokeColor returns null, and this fallback substitutes the bubble fill color instead. CreateBubble and AddBubbleMarker then render a visible 1-point (or retained-width) border, so PNG, SVG, HTML, and PDF snapshots add an outline that the native chart explicitly disabled; carry a distinct no-outline state rather than treating it as a missing color.
Useful? React with 👍 / 👎.
| if (layout.ShowMarkers && currentSeries.ShowMarkers) { | ||
| OfficeColor pointColor = GetPointColor(currentSeries.PointColors, points[i].SourceIndex, color); | ||
| AddMarker(drawing, currentSeries, point, 5D, pointColor, 1.25D); | ||
| if (currentSeries.BubbleSizes != null) { | ||
| AddBubbleMarker(drawing, currentSeries, points[i].SourceIndex, point, |
There was a problem hiding this comment.
Render bubble glyphs independently of marker visibility
When a Bubble snapshot is rendered with OfficeChartLayout(showMarkers: false), this outer condition skips AddBubbleMarker for every point. Because bubble series have no connecting line or other data glyph, the resulting chart contains axes and possibly labels but none of its bubbles; treat bubble glyphs as the chart's data marks rather than optional scatter markers.
Useful? React with 👍 / 👎.
| if (currentSeries.BubbleSizes != null) { | ||
| AddBubbleMarker(drawing, currentSeries, points[i].SourceIndex, point, | ||
| maximumBubbleSize, maximumBubbleDiameter, | ||
| snapshot.BubbleSizeMode, pointColor); | ||
| } else { | ||
| AddMarker(drawing, currentSeries, point, 5D, pointColor, 1.25D); |
There was a problem hiding this comment.
Reject Bubble snapshots without size data
The public Drawing contract permits OfficeChartSnapshot to use OfficeChartKind.Bubble with an ordinary OfficeChartSeries whose BubbleSizes is null. For numeric categories, this fallback renders every point as a fixed-size scatter marker and reports success, even though the requested chart has no bubble-size data; validate the Bubble contract or skip/fail the malformed series instead of silently changing chart families.
Useful? React with 👍 / 👎.
Summary
Adds first-class PowerPoint bubble charts to the shared chart contract. Callers can create a bubble series with X, Y, and per-point size values, then add it with the existing PowerPoint chart APIs.
Bubble data survives save/reopen,
UpdateData(...), accessibility summaries, and the embedded workbook. Shared PNG, SVG, HTML, PDF, and raster output preserves point colors, outline color and width, zero-sized bubbles, native bubble scale, and exact area-versus-width sizing. Numeric ticks, gridlines, labels, and bubble centers share the same radius-safe coordinate map, so large extrema stay inside the plot without drifting away from their axes.Semantic PowerPoint HTML stores X and bubble-size metadata and restores a native bubble chart on import. Malformed semantic data and invalid, non-finite, negative, missing, or mismatched native caches fail through the safe snapshot contract instead of silently changing the chart. Enabled 3-D bubble rendering is rejected because the shared renderers provide a flat bubble-chart surface.
The shared Excel entry point rejects the bubble kind explicitly instead of creating a different chart. Excel callers can continue to use the native Excel bubble-chart API.
Usage
Bubble sizes must be finite and non-negative, with one size for every X/Y point.
Validation
The complete .NET 8 suites pass for Drawing (1,001), PowerPoint (1,407), HTML (1,225), and Excel (2,657), with seven opt-in live/Desktop tests skipped. Focused bubble tests pass on .NET 10. Drawing, PowerPoint, PowerPoint PDF, and PowerPoint HTML build for .NET Standard 2.0 with zero warnings.