Skip to content

Class: Chart ​

A chart graphic-frame's chart, backed by its chart part.

Constructors ​

Constructor ​

new Chart(part): Chart

Parameters ​

ParameterTypeDescription
partPartThe chart's OPC part (/ppt/charts/chartN.xml).

Returns ​

Chart

Properties ​

part ​

readonly part: Part

The chart's OPC part (/ppt/charts/chartN.xml).

Accessors ​

axes ​

Get Signature ​

get axes(): ChartAxis[]

The category/value/series axes (c:catAx/c:valAx/c:dateAx/c:serAx) in plot-area document order. Empty for pie/doughnut charts (no axes).

Returns ​

ChartAxis[]


categories ​

Get Signature ​

get categories(): (string | null)[]

Category labels, read from the first series' cached categories (c:cat), as written. Empty when the chart has no category axis.

Returns ​

(string | null)[]


categoryAxis ​

Get Signature ​

get categoryAxis(): ChartAxis | null

The category axis (c:catAx/c:dateAx), or null when the chart has none.

Returns ​

ChartAxis | null


categoryLevels ​

Get Signature ​

get categoryLevels(): (string | null)[][]

Every category level of the first series, leaf first; see ChartSeries.categoryLevels.

Returns ​

(string | null)[][]


chartType ​

Get Signature ​

get chartType(): string | null

The first chart-group type, or null for an empty plot area.

Returns ​

string | null


chartTypes ​

Get Signature ​

get chartTypes(): string[]

The chart-group type tokens present in the plot area, in document order (e.g. ['line'], ['bar'], ['bar', 'line'] for a combo chart). Derived from the plot-area element local names (lineChart → line).

Returns ​

string[]


dataLabels ​

Get Signature ​

get dataLabels(): ChartDataLabels | null

The chart-level data-label settings, read from the first plot group's aggregate c:dLbls (the group-wide block after the series). null when the plot group carries no data-label block.

A pie keeps its labels on the series instead: PowerPoint writes the flags the user set into c:ser/c:dLbls and leaves this block all off, and this library's writer emits no group block for a pie at all. Read those through ChartSeries.dataLabels.

Returns ​

ChartDataLabels | null


element_ ​

Get Signature ​

get element_(): Element | null

Escape hatch: the underlying c:chartSpace element. After mutating it call markDirty, or save() writes the original bytes.

Returns ​

Element | null


legend ​

Get Signature ​

get legend(): ChartLegend | null

The legend (c:chart/c:legend) position + overlay, or null when hidden.

Returns ​

ChartLegend | null


partName ​

Get Signature ​

get partName(): string

Partname of the chart part.

Returns ​

string


series ​

Get Signature ​

get series(): ChartSeries[]

The data series (c:ser) across all chart groups, in document order.

Returns ​

ChartSeries[]


title ​

Get Signature ​

get title(): string | null

The chart title (c:chart/c:title rich text), or null when absent/auto.

Returns ​

string | null


valueAxis ​

Get Signature ​

get valueAxis(): ChartAxis | null

The (primary) value axis (c:valAx), or null when the chart has none.

Returns ​

ChartAxis | null

Methods ​

markDirty() ​

markDirty(): void

Mark the chart part dirty so save() reserializes it. Call after mutating element_.

Returns ​

void