HotXLS Docs

TXLSXChart and TXLSXCharts classes

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 ValueAxisTitleChart and primary-axis caption text
TitleTextStyle and TitleLayoutTyped chart-title font, colour, emphasis, rotation, overlay and manual position
ShowLegend, LegendPosition, LegendTextStyle and LegendLayoutLegend visibility, side, overlay, font and manual position
PlotAreaLayoutManual inner or outer plot rectangle using normalized ChartML coordinates
FromRow, FromCol, ToRow and ToColOne-based worksheet anchor rectangle
CategoryAxis and ValueAxisPrimary category or X axis and primary value or Y axis
SecondaryCategoryAxis and SecondaryValueAxisTop and right axes used by secondary plot groups
SeriesAxisDepth axis used by three-dimensional category charts
PlotGroupsOrdered chart-family groups that make combination charts possible while Series remains a flattened compatibility view
HasPreservedXmlReports whether the chart retains original ChartML for extension-safe round trips
ShowDataTable and ShowDataTableKeysData-table display controls
ShowDataTableHorzBorder, ShowDataTableVertBorder and ShowDataTableOutlineIndependent data-table border switches emitted as c:showHorzBorder, c:showVertBorder, and c:showOutline; all three default to True
HasDropLines and HasSeriesLinesLine-chart drop lines connect each point to the category axis; series lines connect stacked bar or line series segments
HasUpDownBars, UpDownGapWidth and HasHiLowLinesLine and stock chart display controls
Rotation3DX, Rotation3DY, Elevation3D, Perspective3D and RightAngleAxes3DThree-dimensional chart view controls
HeightPercent3D, DepthPercent3D and GapDepth3DThree-dimensional plot height, depth and series-gap percentages
RadarStyleRadar chart family variant for the current chart type
HoleSize and FirstSliceAngDoughnut inner-radius percentage (10..90) and the start angle in degrees for pie and doughnut charts
OfPieType, OfPieSplitType, OfPieSplitPos, OfPieSecondPieSize and OfPieGapWidthPie-of-pie and bar-of-pie layout, split rule, and primary and secondary plot sizes
RoundedCornersToggles rounded corners for the chart space
AutoTitleDeletedSuppresses the automatic title derived from a single series name and emits c:autoTitleDeleted
ChartBackgroundColor, ChartBorderColor and PlotAreaBackgroundColorChart and plot-area fill and border colours as $RRGGBB values; 0 keeps the theme default
ProtectionEnabled, ProtectedChartObjects, ProtectedDataEditing, ProtectedFormatting, ProtectedSelection and ProtectedUserInterfaceChart protection switch and the individual editing restrictions it emits as c:protection
OwnerSheetRead-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;
TrendlineTypeLinear, exponential, logarithmic, polynomial, power or moving-average trendline
DispEq and DispRSqrShows the equation and R-squared value on the chart
Order and PeriodPolynomial order or moving-average period for the corresponding trendline type
ValueTypeFixed, percentage, standard-deviation, standard-error or custom error magnitude
NoEndCapHides the cap at either end of an error bar

Axis and data-label members

LogBase and OrientationLogarithmic scale base and normal or reversed axis ordering
MajorGridlines and MinorGridlinesGridline visibility controls
MinValue, MaxValue, MajorUnit and MinorUnitExplicit scaling bounds and tick spacing where supported
CrossesAt, TickLblPos and DispUnitsAxis crossing position, label placement and display units
ShowValue, ShowCategoryName, ShowSeriesName, ShowLegendKey, ShowPercent and ShowBubbleSizePer-series data-label components
SeparatorText 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