AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
fix(scripts): native charts follow the fallback drawing — bar order, point markers, area fills, spacing, gaps
hugohe3e5571b7ea8d7
diff --git a/skills/ppt-master/references/native-data-interface.md b/skills/ppt-master/references/native-data-interface.mdindex 7d9b5403..fee9f264 100644--- a/skills/ppt-master/references/native-data-interface.md+++ b/skills/ppt-master/references/native-data-interface.md@@ -34,7 +34,7 @@ python3 skills/ppt-master/scripts/stamp_native_fallbacks.py "<svg-file-or-directThe hash is a synchronization receipt, not proof of semantic equivalence; never stamp stale JSON to satisfy validation.-**Hard rule — activation is the opt-in**: a marker only declares eligibility. Normal `svg_to_pptx.py` converts the fallback children into editable DrawingML shapes; `--native-charts-and-tables` emits the PowerPoint Chart/Table object and skips the fallback children — data-object-first and possibly lossy (marker-local labels, callouts, KPIs, guide lines, custom bins, or styling absent from the payload may normalize; export warns). Loss of visual parity is not grounds to remove a convertible marker; use fallback export when exact artwork matters more.+**Hard rule — activation is the opt-in**: a marker only declares eligibility. Normal `svg_to_pptx.py` converts the fallback children into editable DrawingML shapes; `--native-charts-and-tables` emits the PowerPoint Chart/Table object and discards the fallback children, so everything the fallback shows lives in the payload — data, point emphasis, line/area treatment, spacing, chrome, and companion text — and the final checker's parity findings block that export until they do. A convertible marker stays even when a detail has no native field: it becomes companion text or an unmarked sibling object, never a simpler drawing.| Replacement marker | Native output | Required metadata ||---|---|---|@@ -62,7 +62,7 @@ The hash is a synchronization receipt, not proof of semantic equivalence; never</g>```-**Hard rule — project by the selected authority**: SVG-first metadata describes the same data and visible chrome as its fallback — for a chart every category/point and series value, x/y/size data, visible point colors and labels, line/area treatment, title/axis/legend chrome, companion text, bounds, and typography native export cannot infer; for a table every resolved cell, header/summary line, rectangular span, cell style, alignment, bounds, and typography. JSON-first metadata is the authority and its preview may be approximate. Never simplify the artwork to fit the payload: when the closed payload cannot carry required data or topology, Default returns the native-ready decision upstream and Quick revises it before drawing; only the resolved non-native object stays unmarked, and an explicit `=yes` is never silently ignored. **Per-page verification**: every `=yes` key matches exactly one marker with one JSON child, and `=no` / unlisted objects have none — `rg -n 'data-pptx-replace-with="(chart|table)"|<metadata type="application/json">' <project_path>/svg_output/<current_page>.svg`.+**Hard rule — project by the selected authority**: SVG-first metadata describes the same data and visible chrome as its fallback — for a chart every category/point and series value (`null` for a break in a line), x/y/size data, visible point colors and markers (`line_style` / `point_colors`), line/area treatment (a line over a translucent fill is a `combo` of an area plot and a line plot), title/axis/legend chrome, companion text, bounds, and typography native export cannot infer; bar categories follow payload order top-down, and bar spacing, clustered overlap, and where a line starts inside `plot_area` are read from the fallback; for a table every resolved cell, header/summary line, rectangular span, cell style, alignment, bounds, and typography. JSON-first metadata is the authority and its preview may be approximate. Never simplify the artwork to fit the payload: when the closed payload cannot carry required data or topology, Default returns the native-ready decision upstream and Quick revises it before drawing; only the resolved non-native object stays unmarked, and an explicit `=yes` is never silently ignored. **Per-page verification**: every `=yes` key matches exactly one marker with one JSON child, and `=no` / unlisted objects have none — `rg -n 'data-pptx-replace-with="(chart|table)"|<metadata type="application/json">' <project_path>/svg_output/<current_page>.svg`.### Table schema — `ppt-master.semantic-table.v2`diff --git a/skills/ppt-master/scripts/docs/native-data.md b/skills/ppt-master/scripts/docs/native-data.mdindex 21b61a52..26f4aafc 100644--- a/skills/ppt-master/scripts/docs/native-data.md+++ b/skills/ppt-master/scripts/docs/native-data.md@@ -29,9 +29,10 @@ Cells accept `text`, `fill`, `fill_opacity`, `color`, `align` (`l` / `ctr` / `r`## §2 Chart schemas-- **Category charts** — `column`, `bar`, `line`, `area`, `pie`, `doughnut`, `pieOfPie`, `barOfPie`, `radar`: `categories` plus `series[].values`. Pie-family charts take exactly one series with per-slice colors; `hole_size` is doughnut-only, integer `10..90`, default `75`; no rotation field. Column/bar may set `series[].point_colors` (camelCase `pointColors` is read-compatible; length = values). `data_labels` (column, bar, line, and area plots only, combo plots of those types included; pie-family, radar, scatter/bubble, stock, and ChartEx charts reject it — show their values through companion `notes`) is `true` or an object with `show_value`, `position`, `number_format`, `font_size`, `font_family`, `bold`, `color`, per-point `colors`, and `points` (zero-based `idx` plus optional overrides); positions: clustered column/bar `outside_end` / `inside_end` / `inside_base` / `center`, stacked `inside_end` / `inside_base` / `center`, line `above` / `center` / `best_fit`, area none.-- **Combo** — shared `categories` plus `plots[]` (`type: "column" | "line" | "area"`, own `series`, optional `axis: "secondary"`, optionally own `categories` / `category_numeric` when caches genuinely differ, and `series_indices` for imported identity — same-length unique non-negative integers forming one contiguous `0..N-1` range across plots) or typed `series[]` with per-series `type` / `axis` (adjacent compatible series share a plot). Area series may set `fill_opacity` (`0..1`; `fillOpacity` read-compatible); a line plot with `area_fill: true` exports as an area chart; line/area series may set `line_width` in SVG px (`lineWidth` read-compatible). Export layers areas below columns and lines.-- **Axes** — classic `axes` is a closed object of `category`, `value`, `secondary_category`, `secondary_value`, each with only `kind` (`text` / `date` / `value`), `position`, `visible`, `label_position` (`next_to` / `none` / `low` / `high`), `number_format`, `minimum`, `maximum`, `major_unit` (value axes), `reverse`, `major_gridlines`; single-plot `bar` takes `category` left/right and `value` bottom/top; pie-family rejects `axes`. `scatter` / `bubble` use `x` and `y` roles only (`kind: "value"`; `x.position` bottom/top, `y.position` left/right) with the same fields. Logarithmic scales, minor units/gridlines, crossing values, display units, and tick skipping are unsupported.+- **Category charts** — `column`, `bar`, `line`, `area`, `pie`, `doughnut`, `pieOfPie`, `barOfPie`, `radar`: `categories` plus `series[].values`. Column, bar, line, and area values may be `null` for a gap (the workbook cell stays blank, the cache omits the point, `dispBlanksAs` is `gap`; at least one value per series is a number) — a fallback that breaks one line into segments is two series of the same colour with `null` outside their segment. Pie-family charts take exactly one series with per-slice colors; `hole_size` is doughnut-only, integer `10..90`, default `75`; no rotation field. Column/bar may set `series[].point_colors` (camelCase `pointColors` is read-compatible; length = values). Bar categories run top-down in payload order — the exporter reverses the category axis and moves the value-axis crossing so the value axis keeps its declared position; `axes.category.reverse: false` restores PowerPoint's bottom-up order (column charts stay left-to-right unless `reverse: true`). Bar/column spacing: root `gap_width` (`0..500`, the empty slot share as a percentage of one bar; PowerPoint default `150`) and clustered `overlap` (`-100..100`, the share of one bar the next series covers, negative for a gap); SVG-first export reads both from the fallback bars inside `plot_area` when the payload omits them, JSON-first uses the defaults.+- **Line markers** — `line_style: "lineMarker"` draws a circle at every point in the series colour; `marker_size` (root or per series, SVG px diameter, `2..72` pt after `×0.75`) sizes it. `series[].point_colors` on a line series marks single points: a colour draws that point's marker in that colour, `null` leaves it bare (with `line_style: "line"` only the coloured points carry markers), so an emphasised endpoint is `[null, …, "#C8102E"]`. Area series draw no markers; a line with markers over a fill is a `combo`. `data_labels` (column, bar, line, and area plots only, combo plots of those types included; pie-family, radar, scatter/bubble, stock, and ChartEx charts reject it — show their values through companion `notes`) is `true` or an object with `show_value`, `position`, `number_format`, `font_size`, `font_family`, `bold`, `color`, per-point `colors`, and `points` (zero-based `idx` plus optional overrides); positions: clustered column/bar `outside_end` / `inside_end` / `inside_base` / `center`, stacked `inside_end` / `inside_base` / `center`, line `above` / `center` / `best_fit`, area none.+- **Combo** — shared `categories` plus `plots[]` (`type: "column" | "line" | "area"`, own `series`, optional `axis: "secondary"`, optionally own `categories` / `category_numeric` when caches genuinely differ, and `series_indices` for imported identity — same-length unique non-negative integers forming one contiguous `0..N-1` range across plots) or typed `series[]` with per-series `type` / `axis` (adjacent compatible series share a plot). Area series may set `fill_opacity` (`0..1`; `fillOpacity` read-compatible); a line plot with `area_fill: true` exports as an area chart; line/area series may set `line_width` in SVG px (`lineWidth` read-compatible); column plots take `gap_width` / `overlap`, line plots `line_style` / `marker_size`. An area series is a fill without an outline; `line_width` adds a same-colour outline around the whole region (baseline included), so a fallback that strokes only the top edge — or draws markers on it — is an area plot under a line plot with the same values. Export layers areas below columns and lines.+- **Axes** — classic `axes` is a closed object of `category`, `value`, `secondary_category`, `secondary_value`, each with only `kind` (`text` / `date` / `value`), `position`, `visible`, `label_position` (`next_to` / `none` / `low` / `high`), `number_format`, `minimum`, `maximum`, `major_unit` (value axes), `reverse`, `major_gridlines`, `tick_marks` (`none` default / `out` / `in` / `cross`), tick-label `color` / `font_family` / `font_size` (SVG px) when one axis's labels differ from the chart-wide text style, and on value axes `cross_between` (`between` — points sit between ticks, the default written explicitly because renderers disagree when it is absent — or `mid_category` — the first point sits on the axis edge; SVG-first line/area export reads it from where the fallback line starts inside `plot_area`); single-plot `bar` takes `category` left/right and `value` bottom/top; pie-family rejects `axes`. `position` is honoured through the axis crossing (`top` / `right` cross at the far category, and a reversed crossing axis swaps the ends). `scatter` / `bubble` use `x` and `y` roles only (`kind: "value"`; `x.position` bottom/top, `y.position` left/right) with the same fields. Logarithmic scales, minor units/gridlines, crossing values, display units, and tick skipping are unsupported.- **XY** — `scatter` and `bubble` use `series[].x` + `series[].y` (`bubble` adds one `series[].size` / `sizes` per point), or `series[].points` as `[x, y]` / `[x, y, size]` tuples or `{x, y, size}` objects.- **ChartEx** — `treemap` / `sunburst` (`values` plus `levels[level][point]` or path-style `categories`; treemap `parent_label_layout: "banner" | "overlapping" | "none"` (default `overlapping`), PowerPoint labels only the top level and leaves), `histogram` (`values`), `pareto` / `waterfall` / `funnel` (`categories` + `values`; `waterfall` accepts `subtotals` / `subtotal_indices`), `boxWhisker` (`series[].values`, optional `series[].categories`). ChartEx writes no `<cx:title>` without a payload title (an empty title shows the series name), emits title/subtitle as companion text boxes, and takes `style.colors` / root `colors` into its color-style part. Non-Microsoft renderers show a limited subset.- **Stock** — numeric Excel date serials in `categories` / `dates` plus exactly four series open / high / low / close (`series` with four entries or top-level `open` / `high` / `low` / `close`).@@ -39,4 +40,4 @@ Cells accept `text`, `fill`, `fill_opacity`, `color`, `align` (`l` / `ctr` / `r`## §2 Chart chrome, typography, and color-SVG-first metadata matches the fallback chrome; JSON-first owns it. Metadata sizes use SVG px (`1px = 0.75pt`); `style.font_family` and `title_font_size`, `subtitle_font_size`, `axis_font_size`, `axis_title_font_size`, `legend_font_size`, `note_font_size` are required only when native must preserve typography an SVG-first fallback cannot supply unambiguously (JSON-first never infers from its preview). A string or unbounded-object `title` becomes native `c:title` (`subtitle` line two); a title object with complete `x`, `y`, `width`, `height` becomes a companion text box (partial bounds or `subtitle` fail); `name` names the object; `title`, `subtitle`, and axis-title objects accept `text`, `font_size`, `font_family`, `color`; the checker rejects SVG-first title/axis text absent from the fallback. Axis titles are explicit via `axis_titles` (`category`, `value`, `x`, `y`, `secondary_value`) or the root aliases `category_axis_title`, `value_axis_title`, `x_axis_title`, `y_axis_title`, `secondary_value_axis_title`; `show_value_axis_labels: false` hides numeric tick labels (e.g. a radar without radial coordinates); native legends are opt-in via `show_legend: true` and `legend_position` (`bottom` default; `top` / `left` / `right`). SVG-first parity reads the fallback literally — `style.axis_color` is the dominant stroke among elements whose id or class names `axis`, `style.grid_color` the dominant stroke among those naming `grid` / `gridline`, and a role with no labeled stroke falls back to the marker's dominant stroke (axis and grid lines in different colors need those labels or one steals the other's dominant); numbers match in written form (`286.20` ≠ `286.2`; a payload `73.0` is stored as `73` and renders as `73` under General, so a fallback that shows `73.0` needs `number_format: "0.0"`; a `number_format` on `data_labels` or an axis makes its rendered form, such as `28.0` for `0.0`, an accepted variant), and marker text that is not a category, data label, axis label, or legend entry needs a companion entry. Companion text (`caption`, `source`, `note`, `notes`, `footnote`, `footnotes`) exports as editable text boxes — strings or objects with `text`, `x`, `y`, `width`, `height` (slide coordinates), `font_size`, `color`, `align`, `bold`; use it for captions, sources, center labels, and annotations, and `data_labels` for point values. `style.colors` sets series colors (treemap/sunburst tile palette in order); the exporter writes explicit chart-area fill, plot-area fill, axis, gridline, and label colors (SVG-first infers them from the largest panel `<rect>`, text, and strokes; JSON-first from JSON or stable defaults), overridable under `style` with `chart_area_fill`, `plot_area_fill`, `text_color`, `axis_color`, `grid_color` (`"none"` for transparent); generated payloads use uppercase `#RRGGBB`, with `#RGB`, `rgb()`, and CSS names normalized. Negative bars keep the series fill. The final checker reports every SVG-first parity finding as a warning tagged `(blocks --native-charts-and-tables export)`; that export refuses the same findings as errors, so clear them before exporting the native variant.+SVG-first metadata matches the fallback chrome; JSON-first owns it. Metadata sizes use SVG px (`1px = 0.75pt`); `style.font_family` and `title_font_size`, `subtitle_font_size`, `axis_font_size`, `axis_title_font_size`, `legend_font_size`, `note_font_size` are required only when native must preserve typography an SVG-first fallback cannot supply unambiguously (JSON-first never infers from its preview). A string or unbounded-object `title` becomes native `c:title` (`subtitle` line two); a title object with complete `x`, `y`, `width`, `height` becomes a companion text box (partial bounds or `subtitle` fail); `name` names the object; `title`, `subtitle`, and axis-title objects accept `text`, `font_size`, `font_family`, `color`; the checker rejects SVG-first title/axis text absent from the fallback. Axis titles are explicit via `axis_titles` (`category`, `value`, `x`, `y`, `secondary_value`) or the root aliases `category_axis_title`, `value_axis_title`, `x_axis_title`, `y_axis_title`, `secondary_value_axis_title`; `show_value_axis_labels: false` hides numeric tick labels (e.g. a radar without radial coordinates); native legends are opt-in via `show_legend: true` and `legend_position` (`bottom` default; `top` / `left` / `right`). SVG-first parity reads the fallback literally — `style.axis_color` is the dominant stroke among elements whose id or class names `axis`, `style.grid_color` the dominant stroke among those naming `grid` / `gridline`, and a role with no labeled stroke falls back to the marker's dominant stroke (axis and grid lines in different colors need those labels or one steals the other's dominant); bar/column fills that are not a series or point colour, line-chart circles with no `lineMarker` / `point_colors` (or in a colour neither carries), translucent area fills without `fill_opacity`, a stroked line or markers over a single-type area, and a bar/column fallback whose first and last category labels contradict the resolved `axes.category.reverse` are each reported; numbers match in written form (`286.20` ≠ `286.2`; a payload `73.0` is stored as `73` and renders as `73` under General, so a fallback that shows `73.0` needs `number_format: "0.0"`; a `number_format` on `data_labels` or an axis makes its rendered form, such as `28.0` for `0.0`, an accepted variant), and marker text that is not a category, data label, axis label, or legend entry needs a companion entry. Companion text (`caption`, `source`, `note`, `notes`, `footnote`, `footnotes`) exports as editable text boxes — strings or objects with `text`, `x`, `y`, `width`, `height` (slide coordinates), `font_size`, `color`, `align`, `bold`; use it for captions, sources, center labels, and annotations, and `data_labels` for point values. `style.colors` sets series colors (treemap/sunburst tile palette in order); the exporter writes explicit chart-area fill, plot-area fill, axis, gridline, and label colors (SVG-first infers them from the largest panel `<rect>`, text, and strokes; JSON-first from JSON or stable defaults), overridable under `style` with `chart_area_fill`, `plot_area_fill`, `text_color`, `axis_color`, `grid_color` (`"none"` for transparent); generated payloads use uppercase `#RRGGBB`, with `#RGB`, `rgb()`, and CSS names normalized. Negative bars keep the series fill. The final checker reports every SVG-first parity finding as a warning tagged `(blocks --native-charts-and-tables export)`; that export refuses the same findings as errors, so clear them before exporting the native variant.diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.pyindex 42f148d5..a0209f96 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_data.py@@ -29,6 +29,13 @@ def _chart_number(value: Any) -> int | float:return int(number) if number.is_integer() else number+def _chart_point_value(value: Any) -> int | float | None:+ """A series point: a finite number, or ``null`` for a gap in the series."""+ if value is None:+ return None+ return _chart_number(value)++def _chart_list(value: Any, field_name: str) -> list[Any]:if value is None:return []@@ -290,8 +297,9 @@ def _chart_axes(if not isinstance(raw_config, dict):raise RuntimeError(f"Native PPTX chart axes.{role} must be an object")allowed_fields = {- "kind", "label_position", "major_gridlines", "major_unit",- "maximum", "minimum", "number_format", "position", "reverse",+ "color", "cross_between", "font_family", "font_size", "kind",+ "label_position", "major_gridlines", "major_unit", "maximum",+ "minimum", "number_format", "position", "reverse", "tick_marks","visible",}unknown_fields = set(raw_config) - allowed_fields@@ -375,6 +383,55 @@ def _chart_axes()config["label_position"] = label_position+ raw_color = raw_config.get("color")+ if raw_color is not None:+ color = _hex_or_none(raw_color)+ if color is None:+ raise RuntimeError(f"Native PPTX chart axes.{role}.color must be a colour")+ config["color"] = color+ raw_font_family = raw_config.get("font_family")+ if raw_font_family is not None:+ if not isinstance(raw_font_family, str) or not raw_font_family.strip():+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.font_family must be a non-empty string"+ )+ config["font_family"] = raw_font_family.strip()+ raw_font_size = raw_config.get("font_size")+ if raw_font_size is not None:+ font_size = _number(raw_font_size, f"chart axes.{role}.font_size")+ if font_size <= 0:+ raise RuntimeError(f"Native PPTX chart axes.{role}.font_size must be positive")+ config["font_size"] = font_size++ raw_tick_marks = raw_config.get("tick_marks")+ if raw_tick_marks is not None:+ tick_marks = _compact_key(raw_tick_marks)+ if tick_marks not in {"cross", "in", "none", "out"}:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.tick_marks must be one of: "+ "cross, in, none, out"+ )+ config["tick_marks"] = tick_marks++ raw_cross_between = raw_config.get("cross_between")+ if raw_cross_between is not None:+ if role not in {"value", "secondary_value"}:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.cross_between is unsupported"+ )+ cross_between = {+ "between": "between",+ "midcat": "midCat",+ "midcategory": "midCat",+ "oncategories": "midCat",+ "onticks": "midCat",+ }.get(_compact_key(raw_cross_between))+ if cross_between is None:+ raise RuntimeError(+ f"Native PPTX chart axes.{role}.cross_between must be between or mid_category"+ )+ config["cross_between"] = cross_between+raw_number_format = raw_config.get("number_format")if raw_number_format is not None:if not isinstance(raw_number_format, str):@@ -414,6 +471,14 @@ def _chart_axes(return axes+def _category_axis_reversed(config: dict[str, Any], chart_type: str) -> bool:+ """Bar categories read top-down in payload order unless ``reverse`` says otherwise."""+ reverse = config.get("reverse")+ if reverse is None:+ return chart_type == "bar"+ return bool(reverse)++def _category_axis_is_date(axes: dict[str, dict[str, Any]]) -> bool:return axes.get("category", {}).get("kind") == "date"@@ -730,6 +795,52 @@ def _radar_style(payload: dict[str, Any], alias_style: str | None) -> tuple[str,return style+def _point_color(color: Any, chart_type: str) -> str | None:+ """Hex per-point colour; line series may leave a point unmarked with ``null``."""+ if chart_type == "line" and (color is None or _compact_key(color) == "none"):+ return None+ if color is None:+ raise RuntimeError("Native PPTX chart series point_colors entries must be colours")+ return _clean_hex(color, "#4472C4")+++def _marker_size(source: dict[str, Any], chart_type: str) -> float | None:+ """Line marker diameter in SVG px (``marker_size``), validated for the 2..72pt range."""+ raw = _first_present(source.get("marker_size"), source.get("markerSize"))+ if raw is None:+ return None+ if chart_type != "line":+ raise RuntimeError("Native PPTX chart marker_size applies to line series only")+ size = _number(raw, "chart marker_size")+ if not 2 <= size * 0.75 <= 72:+ raise RuntimeError("Native PPTX chart marker_size must resolve to 2..72pt")+ return size+++def _gap_width(source: dict[str, Any], chart_type: str) -> int | None:+ """Bar/column gap width as a percentage of one bar (``gap_width``, 0..500)."""+ raw = _first_present(source.get("gap_width"), source.get("gapWidth"))+ if raw is None:+ return None+ if chart_type not in {"bar", "column"}:+ raise RuntimeError("Native PPTX chart gap_width applies to bar and column charts only")+ if isinstance(raw, bool) or not isinstance(raw, (int, float)) or not 0 <= raw <= 500:+ raise RuntimeError("Native PPTX chart gap_width must be a number between 0 and 500")+ return int(round(raw))+++def _overlap(source: dict[str, Any], chart_type: str) -> int | None:+ """Bar/column series overlap as a percentage of one bar (``overlap``, -100..100)."""+ raw = source.get("overlap")+ if raw is None:+ return None+ if chart_type not in {"bar", "column"}:+ raise RuntimeError("Native PPTX chart overlap applies to bar and column charts only")+ if isinstance(raw, bool) or not isinstance(raw, (int, float)) or not -100 <= raw <= 100:+ raise RuntimeError("Native PPTX chart overlap must be a number between -100 and 100")+ return int(round(raw))++def _category_series(payload: dict[str, Any],categories: list[Any],@@ -752,18 +863,24 @@ def _category_series(if not isinstance(item, dict):raise RuntimeError("Native PPTX chart series entries must be objects")values = [- _chart_number(value)+ _chart_point_value(value)for value in _chart_list(item.get("values", []), "series[].values")]if len(values) != len(categories):raise RuntimeError("Native PPTX chart series values must match categories length")+ if all(value is None for value in values):+ raise RuntimeError("Native PPTX chart series values must contain a number")+ if chart_type not in {"area", "bar", "column", "line"} and None in values:+ raise RuntimeError(+ f"Native PPTX {chart_type} chart series values cannot contain null gaps"+ )raw_point_colors = _first_present(item.get("point_colors"),item.get("pointColors"),root_point_colors if idx == 1 else None,)point_colors = [- _clean_hex(color, "#4472C4")+ _point_color(color, chart_type)for color in _chart_list(raw_point_colors, "series[].point_colors")]if point_colors and len(point_colors) != len(values):@@ -771,6 +888,9 @@ def _category_series(series_item = {"name": str(item.get("name") or f"Series {idx}"), "values": values}if point_colors:series_item["point_colors"] = point_colors+ marker_size = _marker_size(item, chart_type)+ if marker_size is not None:+ series_item["marker_size"] = marker_sizefill_opacity = _first_present(item.get("fill_opacity"),item.get("fillOpacity"),@@ -882,6 +1002,9 @@ def _category_chart_data("of_pie_type": of_pie_type,"hole_size": _doughnut_hole_size(payload, chart_type),"line_style": line_style,+ "marker_size": _marker_size(payload, chart_type),+ "gap_width": _gap_width(payload, chart_type),+ "overlap": _overlap(payload, chart_type),"radar_marker_style": radar_marker_style,"radar_style": radar_style,"show_value_axis_labels": _chart_bool(@@ -1036,6 +1159,10 @@ def _combo_plot_entry(entry["series_indices"] = series_indicesif chart_type == "line":entry["line_style"] = _line_style(plot_payload, alias_style)+ entry["marker_size"] = _marker_size(plot_payload, chart_type)+ if chart_type == "column":+ entry["gap_width"] = _gap_width(plot_payload, chart_type)+ entry["overlap"] = _overlap(plot_payload, chart_type)return entrydiff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.pyindex 03f0b682..ea5b4d1c 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py@@ -19,7 +19,7 @@ from ..drawingml.utils import (text_has_rtl_characters,text_uses_rtl,)-from .chart_data import _DEFAULT_CHART_COLORS, _chart_data+from .chart_data import _DEFAULT_CHART_COLORS, _category_axis_reversed, _chart_datafrom .marker_common import (_bool_attr,_bounds,@@ -777,6 +777,322 @@ def _native_chart_point_color_warnings(]+def _fallback_data_shapes(elem: ET.Element) -> list[Any]:+ """Painted fallback geometry that is not axis, grid, or legend chrome."""+ return [+ record+ for record in _fallback_shape_records(elem)+ if not _record_has_label(record, "axis", "grid", "legend")+ ]+++def _series_palette(payload: dict[str, Any], series_count: int) -> set[str]:+ style = payload.get("style") if isinstance(payload.get("style"), dict) else {}+ raw_colors = _first_present(style.get("colors"), payload.get("colors"))+ palette = (+ [_clean_hex(color, "#4472C4") for color in raw_colors]+ if isinstance(raw_colors, list) and raw_colors+ else list(_DEFAULT_CHART_COLORS)+ )+ return {palette[idx % len(palette)] for idx in range(series_count)}+++def _typed_series(chart_data: dict[str, Any], chart_type: str) -> list[dict[str, Any]]:+ """Series of one plot type from a category chart or the matching combo plots."""+ if chart_data.get("kind") == "category" and chart_data.get("type") == chart_type:+ return list(chart_data.get("series") or [])+ if chart_data.get("kind") == "combo":+ return [+ item+ for plot in chart_data.get("plots") or []+ if plot.get("type") == chart_type+ for item in plot.get("series") or []+ ]+ return []+++def _native_chart_line_marker_warnings(+ elem: ET.Element,+ payload: dict[str, Any],+ chart_data: dict[str, Any],+) -> list[str]:+ line_series = _typed_series(chart_data, "line")+ if not line_series:+ return []+ dots = [+ record+ for record in _fallback_data_shapes(elem)+ if record.tag in {"circle", "ellipse"} and record.fill is not None+ ]+ if not dots:+ return []+ if chart_data.get("kind") == "category":+ marker_styles = [chart_data.get("line_style")]+ else:+ marker_styles = [+ plot.get("line_style")+ for plot in chart_data.get("plots") or []+ if plot.get("type") == "line"+ ]+ has_markers = "lineMarker" in marker_styles or any(+ item.get("point_colors") for item in line_series+ )+ warnings: list[str] = []+ if not has_markers:+ warnings.append(+ f"Native PPTX line chart fallback draws {len(dots)} point marker(s) "+ "but the payload has none; set line_style \"lineMarker\" (marker_size in px) "+ "for every point, or series point_colors with a colour per marked point "+ "and null elsewhere"+ )+ series_count = (+ len(chart_data.get("series") or [])+ if chart_data.get("kind") == "category"+ else sum(len(plot.get("series") or []) for plot in chart_data.get("plots") or [])+ )+ known = _series_palette(payload, series_count) | {+ color+ for item in line_series+ for color in item.get("point_colors", [])+ if color is not None+ }+ deviations = sorted({+ record.fill for record in dots if record.fill not in known+ })+ warnings.extend(+ f"Native PPTX line marker fill #{color} deviates from its series color, "+ "but series point_colors is absent"+ for color in deviations+ )+ return warnings+++def _native_chart_area_warnings(+ elem: ET.Element,+ payload: dict[str, Any],+ chart_data: dict[str, Any],+) -> list[str]:+ area_series = _typed_series(chart_data, "area")+ if not area_series:+ return []+ shapes = _fallback_data_shapes(elem)+ regions = [+ record+ for record in shapes+ if record.tag in {"path", "polygon"} and record.fill is not None+ ]+ warnings: list[str] = []+ translucent = sorted({+ record.fill_opacity+ for record in regions+ if record.fill_opacity is not None and record.fill_opacity < 1+ })+ if translucent and not any(item.get("fill_opacity") is not None for item in area_series):+ sample = ", ".join(f"{value:g}" for value in translucent[:3])+ warnings.append(+ f"Native PPTX area chart fallback fills are translucent (fill-opacity {sample}) "+ "but no area series sets fill_opacity; native areas export opaque"+ )+ if chart_data.get("kind") != "category":+ return warnings+ strokes = [+ record+ for record in shapes+ if record.tag in {"path", "polyline"} and record.fill is None and record.stroke is not None+ ]+ dots = [+ record+ for record in shapes+ if record.tag in {"circle", "ellipse"} and record.fill is not None+ ]+ outlined = any(item.get("line_width") is not None for item in area_series)+ if (strokes and not outlined) or dots:+ warnings.append(+ "Native PPTX area chart fallback draws a line"+ + (" and point markers" if dots else "")+ + " over the filled region, but an area series exports as a fill without "+ "either; give the series line_width for a same-colour outline, or use type "+ "\"combo\" with an area plot (fill_opacity) under a line plot (line_width, "+ "line_style \"lineMarker\")"+ )+ return warnings+++def _native_chart_category_order_warnings(+ elem: ET.Element,+ payload: dict[str, Any],+ chart_data: dict[str, Any],+) -> list[str]:+ chart_type = chart_data.get("type")+ if chart_data.get("kind") != "category" or chart_type not in {"bar", "column"}:+ return []+ categories = [str(item) for item in chart_data.get("categories") or []]+ if len(categories) < 2:+ return []+ first_text = _normalized_fallback_text(categories[0])+ last_text = _normalized_fallback_text(categories[-1])+ records = [+ record+ for record in _fallback_text_records(elem)+ if not _record_has_label(record, "legend")+ and record.x is not None+ and record.y is not None+ ]+ firsts = [record for record in records if record.text == first_text]+ lasts = [record for record in records if record.text == last_text]+ if len(firsts) != 1 or len(lasts) != 1 or first_text == last_text:+ return []+ first, last = firsts[0], lasts[0]+ axes = chart_data.get("axes") if isinstance(chart_data.get("axes"), dict) else {}+ category = axes.get("category") if isinstance(axes.get("category"), dict) else {}+ resolved = _category_axis_reversed(category, chart_type)+ if chart_type == "bar":+ expected = first.y < last.y+ drawn = "top-down" if expected else "bottom-up"+ else:+ expected = first.x > last.x+ drawn = "right-to-left" if expected else "left-to-right"+ if expected == resolved:+ return []+ return [+ f"Native PPTX {chart_type} chart fallback lists categories {drawn} "+ f"({categories[0]!r} before {categories[-1]!r}) but the payload resolves "+ f"axes.category.reverse to {str(resolved).lower()}; set axes.category.reverse: "+ f"{str(expected).lower()}"+ ]+++def _fallback_bar_clusters(+ elem: ET.Element,+ chart_data: dict[str, Any],+) -> tuple[float, dict[int, list[tuple[float, float]]]] | None:+ """Fallback bars grouped by category slot: slot size plus (low, high) edges per slot."""+ chart_type = chart_data.get("type")+ plot_area = chart_data.get("plot_area")+ if chart_data.get("kind") != "category" or chart_type not in {"bar", "column"}:+ return None+ if not isinstance(plot_area, dict):+ return None+ categories = chart_data.get("categories") or []+ if not categories or not chart_data.get("series"):+ return None+ px, py = float(plot_area["x"]), float(plot_area["y"])+ pw, ph = float(plot_area["width"]), float(plot_area["height"])+ along = 0 if chart_type == "column" else 1 # axis index that carries the categories+ origin = px if along == 0 else py+ extent = pw if along == 0 else ph+ slot = extent / len(categories)+ clusters: dict[int, list[tuple[float, float]]] = {}+ for record in _fallback_data_shapes(elem):+ if record.tag != "rect" or record.fill is None:+ continue+ x0, y0, x1, y1 = record.bounds+ if (x1 - x0) * (y1 - y0) >= 0.9 * pw * ph:+ continue+ cx, cy = (x0 + x1) / 2, (y0 + y1) / 2+ if not (px <= cx <= px + pw and py <= cy <= py + ph):+ continue+ low, high = (x0, x1) if along == 0 else (y0, y1)+ index = min(len(categories) - 1, max(0, int((((low + high) / 2) - origin) // slot)))+ clusters.setdefault(index, []).append((low, high))+ if not clusters:+ return None+ return slot, clusters+++def _median(values: list[float]) -> float:+ ordered = sorted(values)+ return ordered[len(ordered) // 2]+++def _inferred_bar_gap_width(+ elem: ET.Element,+ chart_data: dict[str, Any],+) -> int | None:+ """Read the bar/column gap width from fallback bars inside a known plot area.++ PowerPoint's gapWidth is the empty slot share as a percentage of one bar+ width; the fallback slot is the plot extent divided by the category count.+ """+ grouped = _fallback_bar_clusters(elem, chart_data)+ if grouped is None:+ return None+ slot, clusters = grouped+ cluster = _median([+ max(high for _, high in edges) - min(low for low, _ in edges)+ for edges in clusters.values()+ ])+ if cluster <= 0:+ return None+ if cluster >= slot:+ return 0+ clustered = chart_data.get("grouping") == "clustered"+ bars_per_cluster = len(chart_data.get("series") or []) if clustered else 1+ bar_width = cluster / bars_per_cluster+ return max(0, min(500, int(round((slot - cluster) / bar_width * 100))))+++def _inferred_bar_overlap(+ elem: ET.Element,+ chart_data: dict[str, Any],+) -> int | None:+ """Read clustered bar overlap: the share of one bar that the next bar covers (negative = gap)."""+ if chart_data.get("grouping") != "clustered" or len(chart_data.get("series") or []) < 2:+ return None+ grouped = _fallback_bar_clusters(elem, chart_data)+ if grouped is None:+ return None+ _, clusters = grouped+ pitches: list[float] = []+ widths: list[float] = []+ for edges in clusters.values():+ ordered = sorted(edges)+ if len(ordered) < 2:+ continue+ widths.extend(high - low for low, high in ordered)+ pitches.extend(+ ordered[idx + 1][0] - ordered[idx][0] for idx in range(len(ordered) - 1)+ )+ if not pitches or not widths:+ return None+ bar_width = _median(widths)+ if bar_width <= 0:+ return None+ return max(-100, min(100, int(round((bar_width - _median(pitches)) / bar_width * 100))))+++def _inferred_cross_between(+ elem: ET.Element,+ chart_data: dict[str, Any],+) -> str | None:+ """Read whether fallback line/area points sit between ticks or on the axis edge.++ The first data point of a category line/area starts either half a slot+ inside the plot (``between``) or on the plot edge (``midCat``).+ """+ chart_type = chart_data.get("type")+ plot_area = chart_data.get("plot_area")+ if chart_data.get("kind") != "category" or chart_type not in {"area", "line"}:+ return None+ if not isinstance(plot_area, dict):+ return None+ categories = chart_data.get("categories") or []+ if len(categories) < 2:+ return None+ px, pw = float(plot_area["x"]), float(plot_area["width"])+ slot = pw / len(categories)+ starts = [+ record.bounds[0]+ for record in _fallback_data_shapes(elem)+ if record.tag in {"path", "polygon", "polyline"}+ and (record.bounds[2] - record.bounds[0]) >= slot+ ]+ if not starts:+ return None+ start = min(starts)+ return "midCat" if abs(start - px) < abs(start - (px + slot / 2)) else "between"++def _native_chart_radial_warnings(elem: ET.Element,payload: dict[str, Any],@@ -1057,6 +1373,9 @@ def _native_chart_chrome_warnings(elem: ET.Element, payload: dict[str, Any]) ->warnings.extend(_native_chart_radial_warnings(elem, payload, chart_data))warnings.extend(_native_chart_tile_color_warnings(elem, payload, chart_data))warnings.extend(_native_chart_reverse_text_warnings(elem, payload, chart_data))+ warnings.extend(_native_chart_line_marker_warnings(elem, payload, chart_data))+ warnings.extend(_native_chart_area_warnings(elem, payload, chart_data))+ warnings.extend(_native_chart_category_order_warnings(elem, payload, chart_data))return warningsdiff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.pyindex 1441c907..fcfa1ae1 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_xml.py@@ -17,6 +17,7 @@ from ..drawingml.utils import (from .chart_data import (_DEFAULT_CHART_COLORS,_category_axis_is_date,+ _category_axis_reversed,_chart_list,_chart_plot_area_layout,_data_label_position,@@ -29,17 +30,21 @@ from .chart_style import (_axis_titles,_chart_area_sp_pr_xml,_chart_line_sp_pr_xml,+ _chart_text_entry,_chart_text_entry_color,_chart_text_entry_font_face,_chart_text_entry_font_size,- _chart_text_entry,_chart_text_sizes,_chart_title_is_bounded,_chart_tx_pr_xml,_classic_chart_style,_font_face_xml,+ _inferred_bar_gap_width,+ _inferred_bar_overlap,+ _inferred_cross_between,_major_gridlines_xml,)+from .marker_attributes import native_json_is_authoritativefrom .marker_common import (PACKAGE_REL_TYPE,_bool_attr,@@ -69,6 +74,7 @@ def _number_cache(points = "".join(f'<c:pt idx="{idx}"><c:v>{value}</c:v></c:pt>'for idx, value in enumerate(values)+ if value is not None)return (f'<c:numCache><c:formatCode>{_xml_escape(number_format)}</c:formatCode>'@@ -413,12 +419,45 @@ def _data_point_colors_xml()-def _marker_xml(symbol: str | None) -> str:+def _marker_xml(+ symbol: str | None,+ *,+ size_pt: int | None = None,+ color: str | None = None,+) -> str:if not symbol:return ""if symbol == "none":return '<c:marker><c:symbol val="none"/></c:marker>'- return f'<c:marker><c:symbol val="{_xml_escape(symbol)}"/></c:marker>'+ size_xml = f'<c:size val="{size_pt}"/>' if size_pt is not None else ""+ sp_pr_xml = ""+ if color:+ clean = _clean_hex(color, "#4472C4")+ sp_pr_xml = (+ f'<c:spPr><a:solidFill><a:srgbClr val="{clean}"/></a:solidFill>'+ f'<a:ln><a:solidFill><a:srgbClr val="{clean}"/></a:solidFill></a:ln></c:spPr>'+ )+ return f'<c:marker><c:symbol val="{_xml_escape(symbol)}"/>{size_xml}{sp_pr_xml}</c:marker>'+++def _marker_size_pt(size_px: Any) -> int | None:+ if size_px is None:+ return None+ return max(2, min(72, int(round(float(size_px) * 0.75))))+++def _line_point_markers_xml(+ point_colors: list[str | None],+ *,+ size_pt: int | None,+) -> str:+ """Per-point line markers: a colour marks the point, ``None`` leaves it bare."""+ return "".join(+ f'<c:dPt><c:idx val="{idx}"/>'+ f'{_marker_xml("none" if color is None else "circle", size_pt=size_pt, color=color)}'+ "</c:dPt>"+ for idx, color in enumerate(point_colors)+ )def _series_xml(@@ -428,6 +467,7 @@ def _series_xml(chart_type: str,grouping: str | None = None,line_style: str = "line",+ marker_size: Any = None,radar_marker_style: str | None = None,radar_style: str = "marker",colors: list[str],@@ -465,8 +505,12 @@ def _series_xml(column_index = offset + start_columnfill_opacity = item.get("fill_opacity") if chart_type == "area" else Noneline_width = item.get("line_width") if chart_type in {"area", "line"} else None+ series_color = _chart_color(colors, color_index)+ # An area is a filled region: it draws an outline only when the payload+ # asks for one with line_width, otherwise the fill edge is the shape.color_xml = _series_color_xml(- _chart_color(colors, color_index),+ series_color,+ line=chart_type != "area" or line_width is not None,fill_opacity=fill_opacity,line_width=line_width,)@@ -491,7 +535,19 @@ def _series_xml(disable_negative_invert=True,)if chart_type == "line":- marker_xml = _marker_xml("circle" if line_style == "lineMarker" else "none")+ size_pt = _marker_size_pt(+ item.get("marker_size") if item.get("marker_size") is not None else marker_size+ )+ marker_xml = _marker_xml(+ "circle" if line_style == "lineMarker" else "none",+ size_pt=size_pt,+ color=series_color if line_style == "lineMarker" else None,+ )+ if item.get("point_colors"):+ point_colors_xml = _line_point_markers_xml(+ item["point_colors"],+ size_pt=size_pt,+ )smooth_xml = '<c:smooth val="0"/>'if chart_type == "radar":if radar_style == "filled":@@ -732,6 +788,17 @@ def _xy_series_xml(return "".join(parts)+_DEFAULT_GAP_WIDTH = 150+++def _bar_overlap_xml(grouping: str | None, overlap: int | None) -> str:+ if grouping in {"stacked", "percentStacked"}:+ return '<c:overlap val="100"/>'+ if overlap is None:+ return ""+ return f'<c:overlap val="{overlap}"/>'++def _bar_chart_group_xml(chart_type: str,grouping: str,@@ -741,21 +808,19 @@ def _bar_chart_group_xml(val_ax_id: str,vary_colors: bool = False,data_labels_xml: str = "",+ gap_width: int | None = None,+ overlap: int | None = None,) -> str:bar_dir = "bar" if chart_type == "bar" else "col"vary_colors_xml = '<c:varyColors val="1"/>' if vary_colors else '<c:varyColors val="0"/>'- overlap_xml = (- '<c:overlap val="100"/>'- if grouping in {"stacked", "percentStacked"}- else ""- )+ overlap_xml = _bar_overlap_xml(grouping, overlap)return ("<c:barChart>"f'<c:barDir val="{bar_dir}"/><c:grouping val="{grouping}"/>'f"{vary_colors_xml}"f"{ser_xml}"f"{data_labels_xml}"- '<c:gapWidth val="150"/>'+ f'<c:gapWidth val="{_DEFAULT_GAP_WIDTH if gap_width is None else gap_width}"/>'f"{overlap_xml}"f'<c:axId val="{cat_ax_id}"/><c:axId val="{val_ax_id}"/>'"</c:barChart>"@@ -783,8 +848,10 @@ def _line_area_chart_group_xml()-def _axis_scaling_xml(config: dict[str, Any]) -> str:- orientation = "maxMin" if config.get("reverse") else "minMax"+def _axis_scaling_xml(config: dict[str, Any], *, reverse: bool | None = None) -> str:+ if reverse is None:+ reverse = bool(config.get("reverse"))+ orientation = "maxMin" if reverse else "minMax"maximum = (f'<c:max val="{config["maximum"]}"/>'if config.get("maximum") is not None else ""@@ -796,6 +863,11 @@ def _axis_scaling_xml(config: dict[str, Any]) -> str:return f'<c:scaling><c:orientation val="{orientation}"/>{maximum}{minimum}</c:scaling>'+def _axis_tick_marks(config: dict[str, Any]) -> str:+ """Axis tick marks default to none: generated fallbacks draw labels, not ticks."""+ return str(config.get("tick_marks") or "none")++def _axis_position(config: dict[str, Any], default: str) -> str:return {"bottom": "b",@@ -871,12 +943,17 @@ def _axis_pair_xml()val_number_format = _axis_number_format_xml(value, default_value_format)axis_sp_pr = _chart_line_sp_pr_xml(chart_style.get("axis_color"))- axis_tx_pr = _chart_tx_pr_xml(- axis_font_size,- chart_style.get("text_color"),- font_face=chart_style.get("font_face"),- language=primary_language,- )++ def axis_tx_pr(config: dict[str, Any]) -> str:+ # Tick-label text per axis: the payload's colour/font/size win over+ # the chart-wide text style (category labels dark, value ticks grey).+ return _chart_tx_pr_xml(+ _font_size_hpt(config["font_size"]) if config.get("font_size") else axis_font_size,+ config.get("color") or chart_style.get("text_color"),+ font_face=config.get("font_family") or chart_style.get("font_face"),+ language=primary_language,+ )+cat_title_xml = "" if secondary else _axis_title_xml(_first_present(axis_titles.get("category"), axis_titles.get("x")),font_size=axis_title_font_size,@@ -912,34 +989,54 @@ def _axis_pair_xml('<c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/>''<c:noMultiLvlLbl val="0"/>')- is_combo = chart_type == "combo"- cross_between = ""- if chart_type == "area" and category_kind == "date":- cross_between = '<c:crossBetween val="midCat"/>'- elif chart_type == "stock" or is_combo:- cross_between = '<c:crossBetween val="between"/>'+ # Written explicitly: renderers disagree on the default (LibreOffice+ # starts an unspecified area on the axis edge, PowerPoint between ticks).+ default_cross_between = (+ "midCat" if chart_type == "area" and category_kind == "date" else "between"+ )+ cross_between = (+ f'<c:crossBetween val="{value.get("cross_between") or default_cross_between}"/>'+ )+ cat_tick_marks = _axis_tick_marks(category)+ val_tick_marks = _axis_tick_marks(value)major_unit = (f'<c:majorUnit val="{value["major_unit"]}"/>'if value.get("major_unit") is not None else "")- value_crosses = "max" if secondary else "autoZero"+ # ``crosses`` places an axis at the first (autoZero) or last (max) point of+ # the axis it crosses; a reversed axis swaps those ends, so the crossing+ # follows the requested position XOR the crossing axis orientation. The+ # hidden secondary pair keeps autoZero/max: its crossing sets the area+ # fill baseline, not a visible axis position.+ category_reversed = (+ False if secondary else _category_axis_reversed(category, chart_type)+ )+ value_reversed = False if secondary else bool(value.get("reverse"))+ far_val_pos = "t" if chart_type == "bar" else "r"+ far_cat_pos = "r" if chart_type == "bar" else "t"+ if secondary:+ value_crosses = "max"+ category_crosses = "autoZero"+ else:+ value_crosses = "max" if (val_pos == far_val_pos) != category_reversed else "autoZero"+ category_crosses = "max" if (cat_pos == far_cat_pos) != value_reversed else "autoZero"return (f"<c:{category_tag}>"- f'<c:axId val="{cat_ax_id}"/>{_axis_scaling_xml(category)}'+ f'<c:axId val="{cat_ax_id}"/>{_axis_scaling_xml(category, reverse=category_reversed)}'f'<c:delete val="{cat_delete}"/><c:axPos val="{cat_pos}"/>'f"{cat_gridlines}{cat_title_xml}{cat_number_format}"- '<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'+ f'<c:majorTickMark val="{cat_tick_marks}"/><c:minorTickMark val="none"/>'f'<c:tickLblPos val="{cat_tick_label_pos}"/>'- f"{axis_sp_pr}{axis_tx_pr}"- f'<c:crossAx val="{val_ax_id}"/><c:crosses val="autoZero"/>{category_tail}'+ f"{axis_sp_pr}{axis_tx_pr(category)}"+ f'<c:crossAx val="{val_ax_id}"/><c:crosses val="{category_crosses}"/>{category_tail}'f"</c:{category_tag}>""<c:valAx>"- f'<c:axId val="{val_ax_id}"/>{_axis_scaling_xml(value)}'+ f'<c:axId val="{val_ax_id}"/>{_axis_scaling_xml(value, reverse=value_reversed)}'f'<c:delete val="{val_delete}"/><c:axPos val="{val_pos}"/>'f"{val_gridlines}{val_title_xml}{val_number_format}"- '<c:majorTickMark val="out"/><c:minorTickMark val="none"/>'+ f'<c:majorTickMark val="{val_tick_marks}"/><c:minorTickMark val="none"/>'f'<c:tickLblPos val="{val_tick_label_pos}"/>'- f"{axis_sp_pr}{axis_tx_pr}"+ f"{axis_sp_pr}{axis_tx_pr(value)}"f'<c:crossAx val="{cat_ax_id}"/><c:crosses val="{value_crosses}"/>'f"{cross_between}{major_unit}""</c:valAx>"@@ -1028,6 +1125,7 @@ def _combo_plot_xml(data_label_font_face=chart_style.get("font_face"),language=chart_style.get("primary_language"),line_style=plot.get("line_style", "line"),+ marker_size=plot.get("marker_size"),category_column=int(plot.get("category_column", 1)),color_start_index=start_index,series_indices=plot.get("series_indices"),@@ -1058,6 +1156,8 @@ def _combo_plot_xml(val_ax_id=val_ax_id,vary_colors=any(item.get("point_colors") for item in plot["series"]),data_labels_xml=data_labels_xml,+ gap_width=plot.get("gap_width"),+ overlap=plot.get("overlap"),))elif chart_type in {"area", "line"}:parts.append(_line_area_chart_group_xml(@@ -1209,6 +1309,7 @@ def _chart_plot_xml(chart_type=chart_type,grouping=series_grouping,line_style=chart_data.get("line_style", "line"),+ marker_size=chart_data.get("marker_size"),radar_marker_style=chart_data.get("radar_marker_style"),radar_style=chart_data.get("radar_style", "marker"),colors=colors,@@ -1248,6 +1349,9 @@ def _chart_plot_xml(if chart_type in {"bar", "column"}:bar_dir = "bar" if chart_type == "bar" else "col"grouping = series_grouping+ gap_width = chart_data.get("gap_width")+ if gap_width is None:+ gap_width = _DEFAULT_GAP_WIDTHaxes_xml = _axis_xml(cat_ax_id,val_ax_id,@@ -1260,11 +1364,7 @@ def _chart_plot_xml(show_value_axis_labels=chart_data.get("show_value_axis_labels", True),axes=chart_data.get("axes") or {},)- overlap_xml = (- '<c:overlap val="100"/>'- if grouping in {"stacked", "percentStacked"}- else ""- )+ overlap_xml = _bar_overlap_xml(grouping, chart_data.get("overlap"))vary_colors_xml = ('<c:varyColors val="1"/>'if any(item.get("point_colors") for item in series)@@ -1276,7 +1376,7 @@ def _chart_plot_xml(f"{vary_colors_xml}"f"{ser_xml}"f"{data_labels_xml}"- '<c:gapWidth val="150"/>'+ f'<c:gapWidth val="{gap_width}"/>'f"{overlap_xml}"f'<c:axId val="{cat_ax_id}"/><c:axId val="{val_ax_id}"/>'"</c:barChart>"@@ -1524,6 +1624,34 @@ def _stock_axis_xml()+def _chart_data_with_fallback_geometry(+ elem: ET.Element,+ chart_data: dict[str, Any],+) -> dict[str, Any]:+ """SVG-first only: fill bar spacing and tick crossing from the fallback drawing."""+ if chart_data.get("gap_width") is None:+ inferred_gap_width = _inferred_bar_gap_width(elem, chart_data)+ if inferred_gap_width is not None:+ chart_data = {**chart_data, "gap_width": inferred_gap_width}+ if chart_data.get("overlap") is None:+ inferred_overlap = _inferred_bar_overlap(elem, chart_data)+ if inferred_overlap is not None:+ chart_data = {**chart_data, "overlap": inferred_overlap}+ axes = chart_data.get("axes") or {}+ value_axis = axes.get("value") or {}+ if value_axis.get("cross_between") is None:+ inferred_cross_between = _inferred_cross_between(elem, chart_data)+ if inferred_cross_between is not None:+ chart_data = {+ **chart_data,+ "axes": {+ **axes,+ "value": {**value_axis, "cross_between": inferred_cross_between},+ },+ }+ return chart_data++def _chart_xml(elem: ET.Element,payload: dict[str, Any],@@ -1544,6 +1672,8 @@ def _chart_xml(axis_titles = _axis_titles(payload)chart_style = _classic_chart_style(payload, elem, inherited_styles)chart_style["primary_language"] = primary_language+ if not native_json_is_authoritative(elem):+ chart_data = _chart_data_with_fallback_geometry(elem, chart_data)plot_xml = _chart_plot_xml(chart_data,colors,diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.pyindex a5424d4e..22d61b93 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py@@ -86,6 +86,7 @@ class _FallbackShapeRecord:fill: str | Nonestroke: str | Nonelabels: tuple[str, ...]+ fill_opacity: float | None = None@dataclass(frozen=True)@@ -158,6 +159,22 @@ def _style_attr(elem: ET.Element, name: str) -> str | None:return None+def _own_fill_opacity(elem: ET.Element) -> float | None:+ """The element's own ``opacity`` × ``fill-opacity``, or None when neither is set."""+ result: float | None = None+ for name in ("opacity", "fill-opacity"):+ raw = _style_attr(elem, name)+ if raw is None:+ continue+ try:+ value = float(str(raw).strip().rstrip("%")) / (100.0 if str(raw).strip().endswith("%") else 1.0)+ except ValueError:+ continue+ value = max(0.0, min(1.0, value))+ result = value if result is None else result * value+ return result++def _paint_visible(elem: ET.Element, paint: str) -> bool:for name in ("opacity", f"{paint}-opacity"):raw = _style_attr(elem, name)@@ -579,6 +596,7 @@ def _fallback_shape_records(fill=fill_color,stroke=stroke_color,labels=labels,+ fill_opacity=_own_fill_opacity(elem) if fill_color else None,))diff --git a/skills/ppt-master/scripts/tests/test_native_chart_fidelity.py b/skills/ppt-master/scripts/tests/test_native_chart_fidelity.pynew file mode 100644index 00000000..568d4874--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_native_chart_fidelity.py@@ -0,0 +1,290 @@+"""Native chart export follows the fallback drawing: order, markers, fills, spacing."""++from __future__ import annotations++import sys+import unittest+from pathlib import Path+from xml.etree import ElementTree as ET++SCRIPTS_DIR = Path(__file__).resolve().parents[1]+if str(SCRIPTS_DIR) not in sys.path:+ sys.path.insert(0, str(SCRIPTS_DIR))++from svg_to_pptx.native_objects.chart_data import _chart_data # noqa: E402+from svg_to_pptx.native_objects.chart_style import ( # noqa: E402+ _inferred_bar_gap_width,+ _inferred_bar_overlap,+ _inferred_cross_between,+ _native_chart_chrome_warnings,+)+from svg_to_pptx.native_objects.chart_xml import _chart_xml # noqa: E402++SVG_NS = "http://www.w3.org/2000/svg"+++def _marker(fallback: str) -> ET.Element:+ svg = ET.fromstring(+ f'<svg xmlns="{SVG_NS}" viewBox="0 0 1280 720">'+ '<g id="chart" data-pptx-replace-with="chart">'+ '<metadata type="application/json">{}</metadata>'+ f"{fallback}</g></svg>"+ )+ return svg.find(f"{{{SVG_NS}}}g")+++def _render(payload: dict, fallback: str = "") -> str:+ elem = _marker(fallback)+ return _chart_xml(+ elem,+ payload,+ chart_rels_id="rId1",+ chart_data=_chart_data(payload),+ chart_bounds=(0, 0, 12192000, 6858000),+ ).decode("utf-8")+++def _bar_payload(**extra: object) -> dict:+ payload = {+ "type": "bar",+ "categories": ["A", "B", "C"],+ "series": [{"name": "S", "values": [1, 2, 3]}],+ }+ payload.update(extra)+ return payload+++class CategoryOrderTests(unittest.TestCase):+ def test_bar_categories_read_top_down_with_value_axis_at_bottom(self) -> None:+ xml = _render(_bar_payload())+ cat_ax = xml[xml.index("<c:catAx>"):xml.index("</c:catAx>")]+ val_ax = xml[xml.index("<c:valAx>"):xml.index("</c:valAx>")]+ self.assertIn('<c:orientation val="maxMin"/>', cat_ax)+ self.assertIn('<c:crosses val="autoZero"/>', cat_ax)+ self.assertIn('<c:axPos val="b"/>', val_ax)+ self.assertIn('<c:crosses val="max"/>', val_ax)++ def test_bar_reverse_false_restores_bottom_up_order(self) -> None:+ xml = _render(_bar_payload(axes={"category": {"reverse": False}}))+ cat_ax = xml[xml.index("<c:catAx>"):xml.index("</c:catAx>")]+ val_ax = xml[xml.index("<c:valAx>"):xml.index("</c:valAx>")]+ self.assertIn('<c:orientation val="minMax"/>', cat_ax)+ self.assertIn('<c:crosses val="autoZero"/>', val_ax)++ def test_column_value_axis_on_the_right_crosses_at_the_last_category(self) -> None:+ payload = _bar_payload(type="column", axes={"value": {"position": "right"}})+ xml = _render(payload)+ val_ax = xml[xml.index("<c:valAx>"):xml.index("</c:valAx>")]+ self.assertIn('<c:axPos val="r"/>', val_ax)+ self.assertIn('<c:crosses val="max"/>', val_ax)++ def test_combo_secondary_axes_keep_their_crossing(self) -> None:+ payload = {+ "type": "combo",+ "categories": ["A", "B"],+ "plots": [+ {"type": "column", "series": [{"name": "C", "values": [1, 2]}]},+ {"type": "line", "axis": "secondary", "series": [{"name": "L", "values": [3, 4]}]},+ ],+ }+ xml = _render(payload)+ crossings = [+ xml[idx:idx + 60]+ for idx in range(len(xml))+ if xml.startswith("<c:crosses", idx)+ ]+ self.assertEqual(len(crossings), 4)+ self.assertIn("autoZero", crossings[2])+ self.assertIn("max", crossings[3])++ def test_fallback_order_warning_names_the_expected_reverse(self) -> None:+ payload = _bar_payload(axes={"category": {"reverse": False}})+ fallback = (+ '<text x="10" y="20">A</text><text x="10" y="80">C</text>'+ )+ warnings = _native_chart_chrome_warnings(_marker(fallback), payload)+ self.assertTrue(any("axes.category.reverse: true" in item for item in warnings))+ self.assertEqual(_native_chart_chrome_warnings(_marker(fallback), _bar_payload()), [])+++class LineMarkerTests(unittest.TestCase):+ def test_line_marker_style_writes_sized_coloured_markers(self) -> None:+ payload = {+ "type": "line",+ "line_style": "lineMarker",+ "marker_size": 10,+ "categories": ["A", "B"],+ "series": [{"name": "S", "values": [1, 2]}],+ "style": {"colors": ["#111111"]},+ }+ xml = _render(payload)+ self.assertIn('<c:marker><c:symbol val="circle"/><c:size val="8"/>', xml)+ self.assertIn('<a:srgbClr val="111111"/></a:solidFill><a:ln>', xml)++ def test_point_colors_mark_single_points_and_leave_null_bare(self) -> None:+ payload = {+ "type": "line",+ "categories": ["A", "B", "C"],+ "series": [{+ "name": "S",+ "values": [1, 2, 3],+ "point_colors": [None, None, "#C8102E"],+ }],+ }+ xml = _render(payload)+ self.assertEqual(xml.count("<c:dPt>"), 3)+ self.assertIn(+ '<c:dPt><c:idx val="2"/><c:marker><c:symbol val="circle"/>'+ '<c:spPr><a:solidFill><a:srgbClr val="C8102E"/>',+ xml,+ )+ self.assertIn('<c:dPt><c:idx val="0"/><c:marker><c:symbol val="none"/>', xml)++ def test_bar_point_colors_still_require_colours(self) -> None:+ payload = _bar_payload(series=[{"name": "S", "values": [1, 2, 3], "point_colors": [None, "#111111", "#222222"]}])+ with self.assertRaises(RuntimeError):+ _chart_data(payload)++ def test_marker_warning_fires_only_without_markers(self) -> None:+ fallback = '<circle cx="10" cy="10" r="5" fill="#C8102E"/>'+ payload = {+ "type": "line",+ "categories": ["A", "B"],+ "series": [{"name": "S", "values": [1, 2]}],+ "style": {"colors": ["#111111"]},+ }+ warnings = _native_chart_chrome_warnings(_marker(fallback), payload)+ self.assertEqual(len(warnings), 2)+ self.assertIn("point marker(s)", warnings[0])+ self.assertIn("#C8102E", warnings[1])+ payload["series"][0]["point_colors"] = [None, "#C8102E"]+ self.assertEqual(_native_chart_chrome_warnings(_marker(fallback), payload), [])+++class GapAndFillTests(unittest.TestCase):+ def test_null_values_leave_gaps_in_the_cache(self) -> None:+ payload = {+ "type": "line",+ "categories": ["A", "B", "C"],+ "series": [{"name": "S", "values": [1, None, 3]}],+ }+ xml = _render(payload)+ num_cache = xml[xml.index("<c:numCache>"):xml.index("</c:numCache>")]+ self.assertIn('<c:ptCount val="3"/><c:pt idx="0"><c:v>1</c:v></c:pt><c:pt idx="2">', num_cache)+ self.assertNotIn('<c:pt idx="1">', num_cache)+ self.assertIn('<c:dispBlanksAs val="gap"/>', xml)++ def test_all_null_series_is_rejected(self) -> None:+ payload = {+ "type": "line",+ "categories": ["A", "B"],+ "series": [{"name": "S", "values": [None, None]}],+ }+ with self.assertRaises(RuntimeError):+ _chart_data(payload)++ def test_area_has_no_outline_unless_line_width_is_set(self) -> None:+ payload = {+ "type": "area",+ "categories": ["A", "B"],+ "series": [{"name": "S", "values": [1, 2], "fill_opacity": 0.14}],+ "style": {"colors": ["#111111"]},+ }+ xml = _render(payload)+ self.assertIn('<a:alpha val="14000"/>', xml)+ self.assertIn("<a:ln><a:noFill/></a:ln>", xml[xml.index("<c:ser>"):xml.index("</c:ser>")])+ payload["series"][0]["line_width"] = 3+ xml = _render(payload)+ self.assertIn('<a:ln w="28575">', xml[xml.index("<c:ser>"):xml.index("</c:ser>")])++ def test_area_warnings_report_translucency_and_overlaid_lines(self) -> None:+ fallback = (+ '<path d="M0 0 L10 10 L20 0 Z" fill="#111111" fill-opacity="0.14"/>'+ '<polyline points="0,0 10,10 20,0" fill="none" stroke="#111111"/>'+ )+ payload = {+ "type": "area",+ "categories": ["A", "B", "C"],+ "series": [{"name": "S", "values": [1, 2, 1]}],+ }+ warnings = _native_chart_chrome_warnings(_marker(fallback), payload)+ self.assertEqual(len(warnings), 2)+ self.assertIn("fill-opacity 0.14", warnings[0])+ self.assertIn('type "combo"', warnings[1])+++class SpacingTests(unittest.TestCase):+ def test_explicit_gap_width_and_overlap_are_written(self) -> None:+ xml = _render(_bar_payload(type="column", gap_width=60, overlap=-20))+ self.assertIn('<c:gapWidth val="60"/><c:overlap val="-20"/>', xml)++ def test_gap_width_is_read_from_fallback_columns(self) -> None:+ payload = _bar_payload(+ type="column",+ plot_area={"x": 0, "y": 0, "width": 300, "height": 100},+ )+ fallback = (+ '<rect x="20" y="50" width="60" height="50" fill="#111111"/>'+ '<rect x="120" y="30" width="60" height="70" fill="#111111"/>'+ '<rect x="220" y="10" width="60" height="90" fill="#111111"/>'+ )+ elem = _marker(fallback)+ chart_data = _chart_data(payload)+ self.assertEqual(_inferred_bar_gap_width(elem, chart_data), 67)+ self.assertIn('<c:gapWidth val="67"/>', _render(payload, fallback))++ def test_overlap_is_read_from_clustered_bars(self) -> None:+ payload = {+ "type": "bar",+ "categories": ["A", "B"],+ "series": [{"name": "S1", "values": [1, 2]}, {"name": "S2", "values": [2, 3]}],+ "plot_area": {"x": 0, "y": 0, "width": 200, "height": 100},+ }+ fallback = (+ '<rect x="0" y="10" width="100" height="20" fill="#111111"/>'+ '<rect x="0" y="34" width="120" height="20" fill="#222222"/>'+ '<rect x="0" y="60" width="80" height="20" fill="#111111"/>'+ '<rect x="0" y="84" width="140" height="20" fill="#222222"/>'+ )+ chart_data = _chart_data(payload)+ self.assertEqual(_inferred_bar_overlap(_marker(fallback), chart_data), -20)++ def test_cross_between_follows_the_fallback_start(self) -> None:+ payload = {+ "type": "line",+ "categories": ["A", "B", "C", "D"],+ "series": [{"name": "S", "values": [1, 2, 3, 4]}],+ "plot_area": {"x": 100, "y": 0, "width": 400, "height": 100},+ }+ chart_data = _chart_data(payload)+ centred = '<polyline points="150,10 250,20 350,30 450,40" fill="none" stroke="#111111"/>'+ edged = '<polyline points="100,10 233,20 366,30 500,40" fill="none" stroke="#111111"/>'+ self.assertEqual(_inferred_cross_between(_marker(centred), chart_data), "between")+ self.assertEqual(_inferred_cross_between(_marker(edged), chart_data), "midCat")+ self.assertIn('<c:crossBetween val="midCat"/>', _render(payload, edged))+ self.assertIn('<c:crossBetween val="between"/>', _render(payload))++ def test_axis_text_colour_font_and_size_are_per_axis(self) -> None:+ payload = _bar_payload(axes={+ "category": {"color": "#1A1A1A"},+ "value": {"color": "#6E6E6E", "font_family": "Arial", "font_size": 16},+ })+ xml = _render(payload)+ cat_ax = xml[xml.index("<c:catAx>"):xml.index("</c:catAx>")]+ val_ax = xml[xml.index("<c:valAx>"):xml.index("</c:valAx>")]+ self.assertIn('<a:srgbClr val="1A1A1A"/>', cat_ax)+ self.assertIn('sz="1200"', val_ax)+ self.assertIn('<a:srgbClr val="6E6E6E"/>', val_ax)+ self.assertIn('<a:latin typeface="Arial"/>', val_ax)+ with self.assertRaises(RuntimeError):+ _chart_data(_bar_payload(axes={"value": {"color": "grey-ish"}}))++ def test_tick_marks_default_to_none_and_accept_out(self) -> None:+ self.assertIn('<c:majorTickMark val="none"/>', _render(_bar_payload()))+ xml = _render(_bar_payload(axes={"value": {"tick_marks": "out"}}))+ val_ax = xml[xml.index("<c:valAx>"):xml.index("</c:valAx>")]+ self.assertIn('<c:majorTickMark val="out"/>', val_ax)+++if __name__ == "__main__":+ unittest.main()