Skip to content

cupertino-files / ChartModel

Class: ChartModel

Defined in: src/tsch/charts.ts:137

Constructors

Constructor

new ChartModel(store, object): ChartModel

Defined in: src/tsch/charts.ts:141

Parameters

store

ObjectStore

object

IwaObject

Returns

ChartModel

Properties

object

readonly object: IwaObject

Defined in: src/tsch/charts.ts:139


store

readonly store: ObjectStore

Defined in: src/tsch/charts.ts:138

Accessors

chartType

Get Signature

get chartType(): string

Defined in: src/tsch/charts.ts:161

Chart type as a readable name ("column2D", "pie2D", …).

Returns

string


chartTypeId

Get Signature

get chartTypeId(): number | undefined

Defined in: src/tsch/charts.ts:156

Numeric TSCH.ChartType value.

Returns

number | undefined


columnCount

Get Signature

get columnCount(): number

Defined in: src/tsch/charts.ts:486

Returns

number


hasDefaultData

Get Signature

get hasDefaultData(): boolean

Defined in: src/tsch/charts.ts:374

True when the chart still holds Apple's placeholder data.

Returns

boolean


id

Get Signature

get id(): bigint

Defined in: src/tsch/charts.ts:146

Returns

bigint


rowCount

Get Signature

get rowCount(): number

Defined in: src/tsch/charts.ts:482

Returns

number


seriesDirection

Get Signature

get seriesDirection(): number | undefined

Defined in: src/tsch/charts.ts:415

Whether grid rows are series or categories.

Raw series_direction. Both corpus charts store 1 and lay their series out as rows, which is the arrangement this module's row/series naming assumes; a chart storing something else is read the same way and its direction is exposed here so a caller can tell.

Returns

number | undefined

Methods

addCategory()

addCategory(name, values): number

Defined in: src/tsch/charts.ts:565

Append a category, giving every series a value for it.

Parameters

name

string

values

readonly ChartValue[]

Returns

number


addSeries()

addSeries(name, values): number

Defined in: src/tsch/charts.ts:520

Append a series.

Three things move together: the name list, the grid row, and the id map — a UUID per series that the app uses to track one across a reorder. The series' styling deliberately does not: theme styles are a six-colour palette the app cycles, and per-series overrides live in a sparse array where an absent entry means "use the theme". A new series with no override is therefore correct, not incomplete.

Parameters

name

string

values

readonly ChartValue[]

Returns

number


axisStyle()

axisStyle(kind, index?): ChartAxisStyle | undefined

Defined in: src/tsch/charts.ts:248

The first axis style of a kind, which is the only one most charts have.

Parameters

kind

AxisKind

index?

number = 0

Returns

ChartAxisStyle | undefined


axisStyles()

axisStyles(): ChartAxisStyle[]

Defined in: src/tsch/charts.ts:232

Axis styles, category axes first.

The chart keeps the two kinds in separate repeated fields, so nothing has to be inferred — which matters, because an axis archive populates only its own family of properties and reading a value axis as a category one would silently return undefined for everything.

Returns

ChartAxisStyle[]


columnNames()

columnNames(): string[]

Defined in: src/tsch/charts.ts:388

Category (column) names.

Returns

string[]


data()

data(): ChartValue[][]

Defined in: src/tsch/charts.ts:393

Plotted values, row-major: data()[row][column].

Returns

ChartValue[][]


legendStyle()

legendStyle(): ChartLegendStyle | undefined

Defined in: src/tsch/charts.ts:218

The legend's style archive, if the chart has one of its own.

Returns

ChartLegendStyle | undefined


privatiseStyle()

privatiseStyle(style, field, index?): IwaObject

Defined in: src/tsch/charts.ts:263

Give this chart its own copy of an axis or legend style, if it shares one.

The same hazard as setSeriesFill — these archives live in the document stylesheet and a template hands one to every chart using it — but the reference is a plain TSP.Reference in a repeated field rather than a sparse-array entry, so the repointing differs and the sharing check does not.

Returns the archive to write to, which is the clone when one was made.

Parameters

style

ChartStyleArchive

field

number

index?

number = 0

Returns

IwaObject


removeCategory()

removeCategory(column): boolean

Defined in: src/tsch/charts.ts:585

Remove a category from every series.

Parameters

column

number

Returns

boolean


removeSeries()

removeSeries(row): boolean

Defined in: src/tsch/charts.ts:545

Remove a series, and everything indexed by its position.

The id map renumbers and the sparse style arrays shift down. Skipping either leaves a chart whose styling has slid onto the wrong series — a file that loads without complaint and is visibly wrong.

Parameters

row

number

Returns

boolean


rowNames()

rowNames(): string[]

Defined in: src/tsch/charts.ts:383

Series (row) names.

Returns

string[]


series()

series(): object[]

Defined in: src/tsch/charts.ts:402

Convenience: rows as { name, values }, pairing names with data.

Returns

object[]


seriesStyle()

seriesStyle(index): ChartSeriesStyle | undefined

Defined in: src/tsch/charts.ts:213

The style of one series, if it has its own rather than inheriting.

Parameters

index

number

Returns

ChartSeriesStyle | undefined


seriesStyles()

seriesStyles(): ChartSeriesStyle[]

Defined in: src/tsch/charts.ts:202

Per-series styles, in series order.

Sparse by design — a chart styles the series the template gave a colour to and leaves the rest inheriting — so the returned entries carry their own ChartSeriesStyle.index and there may be fewer than rowCount.

Returns

ChartSeriesStyle[]


setAxisMajorGridlines()

setAxisMajorGridlines(kind, visible, index?): ChartAxisStyle

Defined in: src/tsch/charts.ts:293

Show or hide an axis's major gridlines, copying on write.

The convenience wrapper for the common axis edit; anything else goes through privatiseStyle and the ChartAxisStyle setters.

Parameters

kind

AxisKind

visible

boolean

index?

number = 0

Returns

ChartAxisStyle


setChartType()

setChartType(type): void

Defined in: src/tsch/charts.ts:180

Change the chart type, by name or by raw enum value.

This sets one field. It does not rebuild the style archives, and that is a real limitation rather than an omission: a pie chart's axis styles are meaningless and a scatter chart wants two value axes, so switching between distant geometries leaves styling the previous type chose. Within a family — column ⇄ bar ⇄ stacked, pie ⇄ donut — the same archives apply and the switch is clean, which is why every series carries a fill per geometry (see appearance.ts).

Numbers redraws from the type, so a mismatch shows up as styling that looks untouched, not as a damaged document.

Parameters

type

string | number

Returns

void


setColumnName()

setColumnName(column, name): void

Defined in: src/tsch/charts.ts:499

Parameters

column

number

name

string

Returns

void


setData()

setData(data): void

Defined in: src/tsch/charts.ts:473

Replace the whole grid, keeping its shape.

Parameters

data

readonly readonly ChartValue[][]

Returns

void


setRowName()

setRowName(row, name): void

Defined in: src/tsch/charts.ts:490

Parameters

row

number

name

string

Returns

void


setSeriesFill()

setSeriesFill(index, fill): ChartSeriesStyle

Defined in: src/tsch/charts.ts:322

Set the colour of one series — the safe way.

Series style archives are shared. They live in the document stylesheet, and a template hands the same archive to every chart that uses that palette slot: in one borrowed document a single ChartSeriesStyleArchive is referenced by ten different charts, and nine of the eighteen present are used by more than one. Reaching for ChartSeriesStyle.setFill directly on such an archive recolours every chart sharing it, with nothing in the result to suggest anything unusual happened.

So this copies on write. If the archive is referenced by anything other than this chart it is cloned, this chart's slot is repointed at the clone, and the clone is what gets the new colour. An archive already private to this chart is edited in place.

Returns the style that was actually written, which is the clone when one was made.

Parameters

index

number

fill

Fill

Returns

ChartSeriesStyle


setSeriesValues()

setSeriesValues(row, values): void

Defined in: src/tsch/charts.ts:457

Replace one series' values, keeping the number of categories.

Charts are rectangular: every series must have a value for every category, or the app plots a series shorter than its axis. Supplying a different count is refused rather than padded, because padding with zeroes and padding with gaps look identical in the data and completely different on the page.

Parameters

row

number

values

readonly ChartValue[]

Returns

void


setValue()

setValue(row, column, value): void

Defined in: src/tsch/charts.ts:434

Replace one plotted value.

Nothing else in the archive is indexed by a value, so this is the safe edit: series styling, axes and the id map all key off positions, which do not move.

Parameters

row

number

column

number

value

ChartValue

Returns

void

MIT licensed. Independently made — not by Apple in California. Not affiliated with or endorsed by Apple Inc.