Portable combined charts
Author and edit supported typed XLSX chart models, save and reopen them, and capture their represented appearance into an immutable portable scene through the existing public workbook APIs
The supported profile combines Column, Line and Area plot groups on primary or secondary Cartesian axes, supports multiple ordinary, stacked or percentage Area series, and draws multiple Doughnut series as concentric rings
A separate primary Column and secondary straight Scatter profile retains independent category and numeric X domains, different point counts, three explicit numeric scales and four distinct axis owners
Use the portable headless output pipeline to transfer a captured scene and render it with native Cairo; loading a chart or retaining its caches alone does not establish portable rendering support
The extended combined Cartesian role profile adds finite primary/secondary vertical, horizontal and numeric pairs with several series, explicit crossing baselines and saved-source ownership
Represented native ChartML projection
Ordinary native Style 2 Column, Line, Area and Doughnut profiles can be opened, captured, saved, edited and reopened through the public Workbook path while the source retains its original ChartML and opaque metadata
The bounded projection compares complete represented appearance before recording a detached scene; it keeps axis identity, crossing references, plot-group order and series order, and rejects unmatched active nodes or attributes
Finite equivalences include the recognized Style 102 fallback to Style 2, effective schema defaults, empty effects and equal explicit Latin, East Asian and complex-script typefaces; these rules do not admit arbitrary theme or style changes
TXLSXChartAxis.CrossBetween retains the value-axis category placement setting through import, edits, assignment and serialization: between places categories in bands, while midCat places the first and last categories at the plot endpoints
TXLSXChart.DefaultTextStyle supplies represented chart-space text defaults through the normal ownership and mutation guards; ChartBorderVisible distinguishes a hidden chart outline from an unspecified border color and can restore a hidden outline without discarding unrelated metadata
The represented combined plan draws category tick marks, honors admitted zero/minimum/maximum crossings and retains an invisible secondary category axis at its stored position
Native projected Style 2 axis, tick and gridline RGB values follow the independently observed bounded theme profile; custom themes and unrepresented font effects remain outside that profile
Plot groups and independent axes
TXLSXChart.AddPlotGroup selects the chart family and xlsxAxisPrimary or xlsxAxisSecondary; each group owns its series, category spacing and drawing order
ValueAxis and SecondaryValueAxis collect separate value domains, so a secondary line with values in the thousands does not change the primary columns' scale; declared minimum and maximum endpoints are applied independently, including when only one endpoint is explicit
For Column groups, GapWidth expresses the inter-cluster gap as a percentage of one column's width, rather than the width of the whole series cluster
Automatic tick spacing is bounded and deterministic; it does not reproduce every Excel automatic-scale heuristic
ZOrder controls group paint order with stable ordering for equal values; area stacking and percentage denominators remain local to their own group
The example explicitly declares straight lines, no markers and maximum crossings for the secondary axes; the represented secondary value axis appears at the right and its category axis at the top
uses
SysUtils, Classes, lxHandleX, lxPortableRender,
lxPortableWorkbookCapture;
procedure AddCombinedChart(Workbook: TXLSXWorkbook);
var
Chart: TXLSXChart;
Group: TXLSXChartPlotGroup;
Series: TXLSXChartSeries;
function AddCachedSeries(AGroup: TXLSXChartPlotGroup;
const Name, RGB: WideString;
const Values: array of WideString): TXLSXChartSeries;
var
I: Integer;
begin
Result := AGroup.AddSeries(Name, '', '');
Result.SolidFillHex := RGB;
Result.SolidFillSet := True;
Result.ValueCache.Kind := xlsxChartCacheNumber;
Result.CategoryCache.Kind := xlsxChartCacheString;
for I := 0 to High(Values) do
begin
Result.ValueCache.Add(I, Values[I]);
Result.CategoryCache.Add(I, WideString(Char(Ord('A') + I)));
end;
end;
begin
Chart := TXLSXChart.Create;
try
Chart.ChartType := xlsxChartColumn;
AddCachedSeries(Chart.PlotGroups[0], 'Units', 'CC3333',
['10', '20', '30']);
AddCachedSeries(Chart.PlotGroups[0], 'Targets', '339933',
['20', '15', '25']);
Chart.ValueAxis.MinValue := 0;
Chart.ValueAxis.MaxValue := 40;
Chart.ValueAxis.MajorUnit := 10;
Group := Chart.AddPlotGroup(xlsxChartLine, xlsxAxisSecondary);
Group.ZOrder := 1;
Series := AddCachedSeries(Group, 'Revenue', '3366CC',
['1000', '2000', '1500']);
Series.LineVisible := True;
Series.LineColorRGB := $3366CC;
Series.MarkerSymbol := xlsxMarkerNone;
Series.MarkerSet := True;
Series.Smooth := False;
Series.SmoothSet := True;
Chart.SecondaryValueAxis.MinValue := 0;
Chart.SecondaryValueAxis.MaxValue := 2500;
Chart.SecondaryValueAxis.MajorUnit := 500;
Chart.SecondaryCategoryAxis.Crosses := xlsxCrossesMax;
Chart.SecondaryCategoryAxis.CrossesSet := True;
Chart.SecondaryValueAxis.Crosses := xlsxCrossesMax;
Chart.SecondaryValueAxis.CrossesSet := True;
// AddExisting copies the chart into the worksheet
Workbook.Sheets[1].Charts.AddExisting(Chart);
finally
Chart.Free;
end;
end;
Sheets[1] selects the first worksheet, while Charts[0], PlotGroups[0] and Series[0] select the first item of their respective chart collections
SolidFillSet declares the stored fill as explicit; a fill-only series follows the existing hidden-line convention, so the line series also explicitly enables its connecting line
Save, reopen, edit and capture
The following procedure uses AddCombinedChart above, saves the authored workbook, reopens and edits the actual typed chart, saves the edit, then captures the reopened result through CaptureXLSPortableRenderSnapshot
This example uses the default Windows geometry service; native Linux and macOS capture use the explicit geometry overload with a provider for the workbook's current view generation, as described in native workbook capture
procedure SaveAndCaptureCombined(const AuthoredFile, EditedFile: WideString;
Destination: TStream);
var
Workbook: TXLSXWorkbook;
Owner: IXLSXWorkbookOwner;
Snapshot: IXLSPortableRenderSnapshot;
Limits: TXLSPortableRenderLimits;
begin
Workbook := TXLSXWorkbook.Create;
Owner := Workbook;
try
Workbook.Sheets.Add('Data');
AddCombinedChart(Workbook);
if Workbook.SaveAs(AuthoredFile) <> 1 then
raise Exception.Create('Cannot save the authored workbook');
if Workbook.Open(AuthoredFile) <> 1 then
raise Exception.Create('Cannot reopen the authored workbook');
Workbook.Sheets[1].Charts[0].PlotGroups[1].Series[0].
ValueCache[0].Value := '1750';
Workbook.Sheets[1].Charts[0].SecondaryValueAxis.MaxValue := 3000;
if Workbook.SaveAs(EditedFile) <> 1 then
raise Exception.Create('Cannot save the edited workbook');
if Workbook.Open(EditedFile) <> 1 then
raise Exception.Create('Cannot reopen the edited workbook');
Limits := XLSDefaultPortableRenderLimits;
Snapshot := CaptureXLSPortableRenderSnapshot(Owner,
1, 1, 1, 20, 12, Limits);
SaveXLSPortableRenderSnapshot(Snapshot, Destination, Limits);
finally
Snapshot := nil;
Owner := nil;
end;
end;
The interface owner keeps the workbook alive during capture; the resulting snapshot owns its represented scene and can outlive that owner, while the caller retains ownership of Destination
Capture uses complete stored caches without calculating worksheet formulas; supply finite values with contiguous zero-based value-cache indices and supported category labels or local one-dimensional A1 references
The existing explicit-geometry overload is declared in lxPortableWorkbookCapture; its geometry interface is declared in lxRenderGeometry
function CaptureXLSPortableRenderSnapshot(const Owner: IXLSXWorkbookOwner;
SheetIndex, Row1, Col1, Row2, Col2: Integer;
const Limits: TXLSPortableRenderLimits; const Geometry: IXLSRenderGeometry):
IXLSPortableRenderSnapshot; overload;
Multiple Area series
Set the group's ChartType to xlsxChartArea and use its existing BarGrouping property: xlsxBarGroupClustered selects ordinary overlapping areas, xlsxBarGroupStacked selects stacked areas, and xlsxBarGroupPercentStacked selects percentage areas
Ordinary areas each close to the zero baseline; stacked areas use signed cumulative boundaries in series order, so the next band's lower boundary is the preceding cumulative boundary
For percentage areas, each category's denominator is the sum of the absolute contributions in that group; signed contributions are then accumulated algebraically, and a zero denominator produces zero boundaries for every series in that category
For example, contributions 10 and -30 have denominator 40 and cumulative boundaries 0.25 and -0.50; positive and negative contributions are not accumulated into separate stacks
Pure Area charts place the first and last categories at the plot endpoints by default; axes shared with Column or Line groups use category bands, while explicit Appearance.UseAxisTickControls selects the existing CategoryBetween control
The existing portable area-opacity option still applies; matching every native raster color or alpha blend is outside this profile
Concentric Doughnut rings
A supported Doughnut group draws its first series as the inner ring and subsequent series outward, with equal radial widths between the declared hole and outer radius
HoleSize and FirstSliceAng retain their declared meanings, zero-valued slices are omitted, and a zero-total ring rejects before a scene is published
Each ring is represented by its own slices; drawing an outer ring does not erase already recorded inner rings with a background ellipse
For the admitted Style 2 automatic Doughnut profile without a title or legend, the plot circle uses the centered chart canvas with 11-point margins, matching native observations across five chart sizes and two font sizes
The public capture selects the represented full circle radius; explicit lower-level appearance ratios and geometry overrides keep their existing precedence, and unsupported manual layouts retain their explicit boundary
Empty, nonfinite or too-small circles reject before a partial scene is published; complete outer bounds, center, ring holes and layer order are checked independently
Auto and explicit markers
The qualified combined Line profile resolves automatic marker shapes by the series index across the whole chart, using the repeating cycle Diamond, Square, Triangle, X, Star, Circle, Plus, Dot and Dash
Column and Area series still occupy global series indices; a line following two column series therefore starts at Triangle, rather than restarting the cycle at the first line group
MarkerSet = False selects automatic ownership; MarkerSet = True with xlsxMarkerAuto requests the automatic shape explicitly, while xlsxMarkerNone explicitly suppresses markers
The nine explicit symbols are Circle, Dash, Diamond, Dot, Plus, Square, Star, Triangle and X; Dot and Dash retain different widths, and explicit fill and border colors use MarkerFillSet and MarkerBorderSet so RGB zero can mean explicit black
Declare MarkerSet = True when choosing an explicit MarkerSize from 2 through 72; assigning a positive size while MarkerSet = False does not serialize an explicit marker size and does not override automatic geometry
Unrepresented custom-theme automatic color selection is outside the independently qualified profiles; use explicit represented RGB settings when that distinction matters
Complete edge-mode manual plot rectangles
Version 2.384.403 admits complete nonnegative manual plot rectangles whose position and size modes are both xlsxChartLayoutEdge through the existing portable chart capture profile
An edge-mode width names the normalized right coordinate, and an edge-mode height names the normalized bottom coordinate; they are not added to the left and top positions
For example, left 0.35, top 0.25, right 0.85 and bottom 0.9 describe the same rectangle as factor-mode width 0.5 and height 0.65
Complete edge rectangles require right greater than left and bottom greater than top, with the existing finite scalar and unit-range limits; factor and mixed-mode admission limits remain unchanged
The qualified public capture preserves the same represented primitives through checked XLSX saving, releasing the source, normal reopening, repeated saving and a corrected retry after a reversed edge is refused
Workbook mutation generations may change during editing and reload; the qualification compares complete snapshot content while normalizing only the serialized eight-byte generation field
This repairs admission for a finite existing manual plot profile without changing the layout solver or native placement; title and legend geometry, broader manual layouts, native pixel parity and the remaining original B7 requirements remain separate
Automatic Cartesian plot bounds
Version 2.384.379 resolves absolute inside plot bounds automatically during ordinary public CaptureXLSPortableRenderSnapshot and CaptureXLSPortableViewRenderSnapshot calls for represented Style 2 vertical Column (xlsxChartColumn), Line (xlsxChartLine) and multi-Area (xlsxChartArea) charts when Title = '', ShowLegend = False, PlotAreaLayout.Enabled = False, caller OverridePlotInnerRectangle = False and no trendlines or error bars are attached
IXLSAutomaticChartCapturePreparation prepares and validates all eligible worksheet charts on the read-only view before the first internal or caller geometry getter, charging aggregate byte, character, item and lookup-step budgets up front and releasing transient clones when capture finishes; the bracket is expressed by its two methods, PrepareAutomaticChartCapture(SheetIndex, Limits) for one sheet and ReleaseAutomaticChartCapture when capture finishes
Non-extended combined chart validation admits an invisible secondary category axis (delete="1", Visible = False) when Excel writes crosses="autoZero" or crosses="max" on normal save, while continuing to require crosses="max" whenever a secondary category axis is visible
The shared Cartesian solver derives one plot rectangle from the chart frame (Outer.Left = X + 7, Outer.Top = Y + 7, Outer.Right = X + Width - 15, Outer.Bottom = Y + Height - 15), 16x subpixel-scaled text measurements (Font.Size <= 256), measured font line heights (Max(0, LabelHeight * 0.74 - 4) on visible vertical value axes, Max(0, CategoryHeight * 0.50 - 4) on external horizontal category axes and top half-height guard Y + LabelHeight / 2 + 1), endpoint category half-width overhang when CategoryBetween = False and internal zero-crossing label placement without reserving an unused external bottom band
Explicit caller plot overrides and the configured CreateReadOnlyViewWithChartAppearance declaration route retain their existing precedence and byte-identical output
Bounds and remaining profiles
The profile accepts at most 16 plot groups, 256 total series and 100,000 dense points per series, subject to the caller's stricter scene-item, byte and text limits; represented cache and configuration values are copied into an owned snapshot before recording
Unsupported input raises EXLSPortableRender before a partial scene is published; the new Cartesian profile accepts straight lines and retains the existing rejection of smoothing that the recorder does not implement
Preserved native ChartML still passes the exact represented-appearance gate; arbitrary native imports that fail that gate remain rejected, and removing preserved XML is not a supported way to bypass an unrepresented appearance
Classic combination expansion, additional secondary Scatter families or Bar combinations, unrepresented date or logarithmic axes, reversed axes, richer crossing and manual-layout geometry, combined annotation profiles beyond the finite detached declared-plot recorder, annotation capture beyond the finite configured workbook view, and arbitrary native style reproduction remain separate work
Representative Windows public author/edit/save/reopen checks, independent package and scene checks, actual Linux Cairo SVG/PNG output, and four native package object-model checks qualify these bounded paths; these checks do not establish complete image-layer equivalence or completion of every combined-chart profile
The retained native input set contains thirteen supported ordinary combination, Area and Doughnut workbooks; the multi-series Pie and Radar observations retain their earlier refusal
Representative public lifecycle, preserved metadata, owned-property and malformed-input checks accompany actual Linux Cairo output; circular absolute geometry and normalized colored topology are independently compared with native output
Version 2.384.379 qualifies automatic Cartesian plot bounds within 0.5 points on each inside edge and 1.0 native pixel on same-frame axis and gridline centerlines across seven discovery and two held-out specimens; manual layouts, titled or legend-bearing automatic layouts, complete raster image equality, arbitrary native styles and completion of every original B7 requirement remain separate