TXLSXCharts is the embedded-chart collection exposed by TXLSXWorksheet.Charts and TXLSXChart owns the chart placement, axes and series
Declarations
function TXLSXCharts.Add: TXLSXChart; overload;
function TXLSXCharts.Add(AChartType: TXLSXChartType; const ATitle: WideString; AFromRow, AFromCol, AToRow, AToCol: Integer): TXLSXChart; overload;
function TXLSXChart.AddSeries(const AName, ACategories, AValues: WideString): TXLSXChartSeries;
function TXLSXChart.AddPlotGroup(AChartType: TXLSXChartType; AAxisGroup: TXLSXChartAxisGroup = xlsxAxisPrimary): TXLSXChartPlotGroup;
procedure TXLSXChart.ClearSeries;
procedure TXLSXChart.ClearPlotGroups;
procedure TXLSXChart.ClearPreservedXml;
property TXLSXChart.ChartType: TXLSXChartType;
property TXLSXChart.HasPreservedXml: Boolean;
property TXLSXChart.CategoryAxis, ValueAxis: TXLSXChartAxis;
property TXLSXChart.SecondaryCategoryAxis, SecondaryValueAxis: TXLSXChartAxis;
property TXLSXChart.SeriesAxis: TXLSXChartAxis;
property TXLSXChart.TitleTextStyle, LegendTextStyle: TXLSXChartTextStyle;
property TXLSXChart.PlotAreaLayout, TitleLayout, LegendLayout: TXLSXChartLayout;
property TXLSXChart.ShowLegend, TitleOverlay, LegendOverlay: Boolean;
property TXLSXChart.LegendPosition: TXLSXChartLegendPosition;
property TXLSXChart.Series[Index: Integer]: TXLSXChartSeries;
property TXLSXChart.PlotGroups[Index: Integer]: TXLSXChartPlotGroup;
property TXLSXChart.RadarStyle: TXLSXChartRadarStyle;
property TXLSXChart.HoleSize, FirstSliceAng: Integer;
property TXLSXChart.OfPieType: TXLSXChartOfPieType;
property TXLSXChart.OfPieSplitType: TXLSXChartOfPieSplitType;
property TXLSXChart.OfPieSplitPos, OfPieSecondPieSize, OfPieGapWidth: Integer;
property TXLSXChart.RoundedCorners, AutoTitleDeleted: Boolean;
property TXLSXChart.ChartBackgroundColor, ChartBorderColor, PlotAreaBackgroundColor: LongWord;
property TXLSXChart.ProtectionEnabled: Boolean;
property TXLSXChart.ProtectedChartObjects, ProtectedDataEditing, ProtectedFormatting, ProtectedSelection, ProtectedUserInterface: Boolean;
property TXLSXChart.ShowDataTableHorzBorder, ShowDataTableVertBorder, ShowDataTableOutline: Boolean;
property TXLSXChart.HasDropLines, HasSeriesLines: Boolean;
property TXLSXChart.OwnerSheet: TXLSXWorksheet;
Chart members
| Title, CategoryAxisTitle and ValueAxisTitle | Chart and primary-axis caption text |
| TitleTextStyle and TitleLayout | Typed chart-title font, colour, emphasis, rotation, overlay and manual position |
| ShowLegend, LegendPosition, LegendTextStyle and LegendLayout | Legend visibility, side, overlay, font and manual position |
| PlotAreaLayout | Manual inner or outer plot rectangle using normalized ChartML coordinates |
| FromRow, FromCol, ToRow and ToCol | One-based worksheet anchor rectangle |
| CategoryAxis and ValueAxis | Primary category or X axis and primary value or Y axis |
| SecondaryCategoryAxis and SecondaryValueAxis | Top and right axes used by secondary plot groups |
| SeriesAxis | Depth axis used by three-dimensional category charts |
| PlotGroups | Ordered chart-family groups that make combination charts possible while Series remains a flattened compatibility view |
| HasPreservedXml | Reports whether the chart retains original ChartML for extension-safe round trips |
| ShowDataTable and ShowDataTableKeys | Data-table display controls |
| ShowDataTableHorzBorder, ShowDataTableVertBorder and ShowDataTableOutline | Independent data-table border switches emitted as c:showHorzBorder, c:showVertBorder, and c:showOutline; all three default to True |
| HasDropLines and HasSeriesLines | Line-chart drop lines connect each point to the category axis; series lines connect stacked bar or line series segments |
| HasUpDownBars, UpDownGapWidth and HasHiLowLines | Line and stock chart display controls |
| Rotation3DX, Rotation3DY, Elevation3D, Perspective3D and RightAngleAxes3D | Three-dimensional chart view controls |
| HeightPercent3D, DepthPercent3D and GapDepth3D | Three-dimensional plot height, depth and series-gap percentages |
| RadarStyle | Radar chart family variant for the current chart type |
| HoleSize and FirstSliceAng | Doughnut inner-radius percentage (10..90) and the start angle in degrees for pie and doughnut charts |
| OfPieType, OfPieSplitType, OfPieSplitPos, OfPieSecondPieSize and OfPieGapWidth | Pie-of-pie and bar-of-pie layout, split rule, and primary and secondary plot sizes |
| RoundedCorners | Toggles rounded corners for the chart space |
| AutoTitleDeleted | Suppresses the automatic title derived from a single series name and emits c:autoTitleDeleted |
| ChartBackgroundColor, ChartBorderColor and PlotAreaBackgroundColor | Chart and plot-area fill and border colours as $RRGGBB values; 0 keeps the theme default |
| ProtectionEnabled, ProtectedChartObjects, ProtectedDataEditing, ProtectedFormatting, ProtectedSelection and ProtectedUserInterface | Chart protection switch and the individual editing restrictions it emits as c:protection |
| OwnerSheet | Read-only reference to the worksheet that owns this chart |
Chart types and combination groups
TXLSXChartType includes column, bar, line, pie, area, doughnut, scatter, bubble, radar, stock, of-pie, surface, surface 3D, column 3D, bar 3D, line 3D, pie 3D and area 3D families
The first plot group is the compatibility group controlled by ChartType and AddSeries Additional groups are added with AddPlotGroup and can use either xlsxAxisPrimary or xlsxAxisSecondary
Series, trendlines and error bars
function TXLSXChartSeries.AddTrendline(AType: TXLSXChartTrendlineType): TXLSXChartTrendline;
function TXLSXChartSeries.AddErrorBar(ADir: TXLSXChartErrDir): TXLSXChartErrBar;
property TXLSXChartSeries.Trendlines[Index: Integer]: TXLSXChartTrendline;
property TXLSXChartSeries.ErrBarX, ErrBarY: TXLSXChartErrBar;
property TXLSXChartTrendline.TrendlineType: TXLSXChartTrendlineType;
property TXLSXChartTrendline.DispEq, DispRSqr: Boolean;
property TXLSXChartTrendline.Order, Period: Integer;
property TXLSXChartErrBar.ValueType: TXLSXChartErrValType;
property TXLSXChartErrBar.Value, PlusValue, MinusValue: Double;
| TrendlineType | Linear, exponential, logarithmic, polynomial, power or moving-average trendline |
| DispEq and DispRSqr | Shows the equation and R-squared value on the chart |
| Order and Period | Polynomial order or moving-average period for the corresponding trendline type |
| ValueType | Fixed, percentage, standard-deviation, standard-error or custom error magnitude |
| NoEndCap | Hides the cap at either end of an error bar |
Axis and data-label members
| LogBase and Orientation | Logarithmic scale base and normal or reversed axis ordering |
| MajorGridlines and MinorGridlines | Gridline visibility controls |
| MinValue, MaxValue, MajorUnit and MinorUnit | Explicit scaling bounds and tick spacing where supported |
| CrossesAt, TickLblPos and DispUnits | Axis crossing position, label placement and display units |
ShowValue, ShowCategoryName, ShowSeriesName, ShowLegendKey, ShowPercent and ShowBubbleSize | Per-series data-label components |
| Separator | Text used between multiple displayed data-label components |
Preserving unsupported ChartML
When TXLSXWorkbook.PreserveUnsupportedParts is enabled, which is the default, an imported chart retains its original ChartML An untouched chart replays that XML without normalization, while changes to typed properties overlay the generated HotXLS model onto the original tree
Unknown namespaces, markup-compatibility AlternateContent, extension lists, custom styles, and unmodelled formatting remain attached to their original chart objects during known-property edits Call ClearPreservedXml to discard this retained XML for one chart and regenerate it only from typed properties
Example
var
Chart: TXLSXChart;
Secondary: TXLSXChartPlotGroup;
begin
Chart := Sheet.Charts.Add(xlsxChartLine, 'Monthly sales', 2, 5, 18, 12);
Chart.AddSeries('Sales', 'Sheet1!$A$2:$A$13', 'Sheet1!$B$2:$B$13');
Chart.ValueAxisTitle := 'Amount';
Chart.TitleTextStyle.Name := 'Aptos Display';
Chart.TitleTextStyle.Size := 18;
Chart.TitleTextStyle.Bold := True;
Chart.PlotAreaLayout.Target := xlsxChartLayoutInner;
Chart.PlotAreaLayout.SetPositionAndSize(0.12, 0.18, 0.72, 0.64);
Chart.ShowLegend := True;
Chart.LegendPosition := xlsxChartLegendBottom;
Chart.LegendTextStyle.Size := 10;
Secondary := Chart.AddPlotGroup(xlsxChartColumn, xlsxAxisSecondary);
Secondary.AddSeries('Margin', 'Sheet1!$A$2:$A$13', 'Sheet1!$C$2:$C$13');
Chart.SecondaryValueAxis.Title := 'Margin percent';
Chart.Series[0].AddTrendline(xlsxTrendLinear).DispRSqr := True;
Chart.Series[0].ShowValue := True;
end;See also