OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
OpenXLSX::XLChart Class Referencefinal

#include <XLChart.hpp>

Inheritance diagram for OpenXLSX::XLChart:
OpenXLSX::XLXmlFile

Public Member Functions

 XLChart ()
 Constructor.
 XLChart (XLXmlData *xmlData)
 Constructor from XLXmlData.
 XLChart (const XLChart &other)=default
 Copy Constructor.
 XLChart (XLChart &&other) noexcept=default
 Move Constructor.
 ~XLChart ()=default
 Destructor.
XLChart & operator= (const XLChart &other)=default
 Copy Assignment Operator.
XLChart & operator= (XLChart &&other) noexcept=default
 Move Assignment Operator.
XLChartSeries addSeries (const XLWorksheet &wks, const XLCellRange &values, std::string_view title="", std::optional< XLChartType > targetChartType=std::nullopt, bool useSecondaryAxis=false)
 Add a data series to the chart.
XLChartSeries addSeries (const XLWorksheet &wks, const XLCellRange &values, const XLCellRange &categories, std::string_view title="", std::optional< XLChartType > targetChartType=std::nullopt, bool useSecondaryAxis=false)
XLChartSeries addSeries (std::string_view valuesRef, std::string_view title="", std::string_view categoriesRef="", std::optional< XLChartType > targetChartType=std::nullopt, bool useSecondaryAxis=false)
XLChartSeries addBubbleSeries (std::string_view xValRef, std::string_view yValRef, std::string_view sizeRef, std::string_view title="")
 Add a bubble chart series with explicit X, Y, and size ranges.
XLChartSeries addBubbleSeries (const XLWorksheet &wks, const XLCellRange &xValues, const XLCellRange &yValues, const XLCellRange &sizes, std::string_view title="")
void setTitle (std::string_view title)
 Set the chart title.
void setStyle (uint8_t styleId)
 Set the built-in chart style ID (1–48).
void setLegendPosition (XLLegendPosition position)
 Set the legend position or hide it.
XLAxis xAxis () const
 Get the X-axis (typically bottom category axis).
XLAxis yAxis () const
 Get the Y-axis (typically left value axis).
XLAxis axis (std::string_view position) const
void setShowDataLabels (bool showValue, bool showCategory=false, bool showPercent=false)
 Configure the display of data labels on the chart.
void setSeriesSmooth (uint32_t seriesIndex, bool smooth)
 Set whether a specific series should be rendered with a smooth line.
void setSeriesMarker (uint32_t seriesIndex, XLMarkerStyle style)
 Set the marker style for a specific series.
void setGapWidth (uint32_t percent)
 Set the gap width between bar/column clusters.
void setOverlap (int32_t percent)
 Set the overlap between bars/columns within a cluster.
void setHoleSize (uint8_t percent)
 Set the size of the hole in a doughnut chart.
void setRotation (uint16_t x, uint16_t y, uint16_t perspective=30)
 Set the rotation of a 3D chart.
void setPlotAreaColor (std::string_view hexRGB)
 Fill the chart plot area with a solid color.
void setChartAreaColor (std::string_view hexRGB)
 Fill the outermost chart space background with a solid color.
void setShowDataTable (bool showTable, bool showKeys=false)
Public Member Functions inherited from OpenXLSX::XLXmlFile
 XLXmlFile ()=default
 Default constructor.
std::string xmlData (XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
 Method for getting the XML data represented by the object.
 XLXmlFile (XLXmlData *xmlData)
 Constructor. Creates an object based on the xmlData input.
 XLXmlFile (const XLXmlFile &other)=default
 Copy constructor. Default implementation used.
 XLXmlFile (XLXmlFile &&other) noexcept=default
 Move constructor. Default implementation used.
 ~XLXmlFile ()=default
 Destructor. Default implementation used.
bool valid () const
 check whether class is linked to a valid XML file
XLXmlFile & operator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
XLXmlFile & operator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
XLDocument & parentDoc ()
 This function provides access to the parent XLDocument object.
const XLDocument & parentDoc () const
 This function provides access to the parent XLDocument object.
XLPackageServices & package ()
 Narrow package-services port (archive, managed XML parts, relationships, content types).
const XLPackageServices & package () const
XLPackagePartFactory & partFactory ()
 Narrow package-part factory port (chart / drawing / image / slicer / sheet accessories).
const XLPackagePartFactory & partFactory () const
const XLSharedStringTable & sharedStringTable () const
 Read-only shared string table (SST) port.
const XLSharedStrings & sharedStrings () const
 Full workbook SST (including getOrCreate / append).
XMLDocument & xmlDocument ()
 This function provides access to the underlying XMLDocument object.
const XMLDocument & xmlDocument () const
 This function provides access to the underlying XMLDocument object.
std::string getXmlPath () const
 Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.
const XLXmlData * xmlDataPart () const noexcept
 Access the underlying XLXmlData pointer.
XLXmlData * xmlDataPart () noexcept

Friends

class XLDocument

Additional Inherited Members

Protected Member Functions inherited from OpenXLSX::XLXmlFile
void setXmlData (std::string_view xmlData)
 Provide the XML data represented by the object.
std::string relationshipID () const
 This function returns the relationship ID (the ID used in the XLRelationships objects) for the object.
Protected Attributes inherited from OpenXLSX::XLXmlFile
XLXmlData * m_xmlData {nullptr}

Constructor & Destructor Documentation

◆ XLChart() [1/4]

OpenXLSX::XLChart::XLChart ( )
inline

Constructor.

◆ XLChart() [2/4]

OpenXLSX::XLChart::XLChart ( XLXmlData * xmlData)
explicit

Constructor from XLXmlData.

Parameters
xmlDatathe source XML data

◆ XLChart() [3/4]

OpenXLSX::XLChart::XLChart ( const XLChart & other)
default

Copy Constructor.

Parameters
otherThe object to be copied

◆ XLChart() [4/4]

OpenXLSX::XLChart::XLChart ( XLChart && other)
defaultnoexcept

Move Constructor.

◆ ~XLChart()

OpenXLSX::XLChart::~XLChart ( )
default

Destructor.

Member Function Documentation

◆ addBubbleSeries() [1/2]

XLChartSeries XLChart::addBubbleSeries ( const XLWorksheet & wks,
const XLCellRange & xValues,
const XLCellRange & yValues,
const XLCellRange & sizes,
std::string_view title = "" )

◆ addBubbleSeries() [2/2]

XLChartSeries XLChart::addBubbleSeries ( std::string_view xValRef,
std::string_view yValRef,
std::string_view sizeRef,
std::string_view title = "" )

Add a bubble chart series with explicit X, Y, and size ranges.

Parameters
xValRefCell reference for X values (e.g. "Sheet1!$A$2:$A$10").
yValRefCell reference for Y values.
sizeRefCell reference for bubble sizes.
titleOptional series name.

◆ addSeries() [1/3]

XLChartSeries XLChart::addSeries ( const XLWorksheet & wks,
const XLCellRange & values,
const XLCellRange & categories,
std::string_view title = "",
std::optional< XLChartType > targetChartType = std::nullopt,
bool useSecondaryAxis = false )

◆ addSeries() [2/3]

XLChartSeries XLChart::addSeries ( const XLWorksheet & wks,
const XLCellRange & values,
std::string_view title = "",
std::optional< XLChartType > targetChartType = std::nullopt,
bool useSecondaryAxis = false )

Add a data series to the chart.

Parameters
valuesRefA cell reference to the data values (e.g. "Sheet1!$B$1:$B$10")
titleA literal string or cell reference for the series name.
categoriesRefA cell reference for the X-axis categories.

◆ addSeries() [3/3]

XLChartSeries OpenXLSX::XLChart::addSeries ( std::string_view valuesRef,
std::string_view title = "",
std::string_view categoriesRef = "",
std::optional< XLChartType > targetChartType = std::nullopt,
bool useSecondaryAxis = false )

◆ axis()

XLAxis XLChart::axis ( std::string_view position) const
nodiscard

◆ operator=() [1/2]

XLChart & OpenXLSX::XLChart::operator= ( const XLChart & other)
default

Copy Assignment Operator.

◆ operator=() [2/2]

XLChart & OpenXLSX::XLChart::operator= ( XLChart && other)
defaultnoexcept

Move Assignment Operator.

◆ setChartAreaColor()

void XLChart::setChartAreaColor ( std::string_view hexRGB)

Fill the outermost chart space background with a solid color.

Parameters
hexRGBSix-character hex color.

◆ setGapWidth()

void XLChart::setGapWidth ( uint32_t percent)

Set the gap width between bar/column clusters.

Parameters
percentGap expressed as a percentage of bar width (0–500, default 150).

◆ setHoleSize()

void XLChart::setHoleSize ( uint8_t percent)

Set the size of the hole in a doughnut chart.

Parameters
percentHole size as a percentage of the chart diameter (1–90, default 75).

◆ setLegendPosition()

void OpenXLSX::XLChart::setLegendPosition ( XLLegendPosition position)

Set the legend position or hide it.

◆ setOverlap()

void XLChart::setOverlap ( int32_t percent)

Set the overlap between bars/columns within a cluster.

Parameters
percentOverlap in percent (−100 to 100). Positive = overlap, negative = gap.

◆ setPlotAreaColor()

void XLChart::setPlotAreaColor ( std::string_view hexRGB)

Fill the chart plot area with a solid color.

Parameters
hexRGBSix-character hex color, e.g. "F2F2F2".

◆ setRotation()

void XLChart::setRotation ( uint16_t x,
uint16_t y,
uint16_t perspective = 30 )

Set the rotation of a 3D chart.

Parameters
xRotation around the X-axis in degrees (0–90).
yRotation around the Y-axis in degrees (0–360).
perspectivePerspective value (0–100, default 30).

◆ setSeriesMarker()

void XLChart::setSeriesMarker ( uint32_t seriesIndex,
XLMarkerStyle style )

Set the marker style for a specific series.

◆ setSeriesSmooth()

void XLChart::setSeriesSmooth ( uint32_t seriesIndex,
bool smooth )

Set whether a specific series should be rendered with a smooth line.

◆ setShowDataLabels()

void XLChart::setShowDataLabels ( bool showValue,
bool showCategory = false,
bool showPercent = false )

Configure the display of data labels on the chart.

◆ setShowDataTable()

void XLChart::setShowDataTable ( bool showTable,
bool showKeys = false )

◆ setStyle()

void OpenXLSX::XLChart::setStyle ( uint8_t styleId)

Set the built-in chart style ID (1–48).

◆ setTitle()

void OpenXLSX::XLChart::setTitle ( std::string_view title)

Set the chart title.

◆ xAxis()

XLAxis XLChart::xAxis ( ) const
nodiscard

Get the X-axis (typically bottom category axis).

◆ yAxis()

XLAxis XLChart::yAxis ( ) const
nodiscard

Get the Y-axis (typically left value axis).

◆ XLDocument

friend class XLDocument
friend

The documentation for this class was generated from the following files:
  • /home/runner/work/OpenXLSX-NX/OpenXLSX-NX/OpenXLSX/headers/XLChart.hpp
  • /home/runner/work/OpenXLSX-NX/OpenXLSX-NX/OpenXLSX/sources/XLChart.cpp
  • /home/runner/work/OpenXLSX-NX/OpenXLSX-NX/OpenXLSX/sources/XLChart_Init.cpp