Most of these functions only read. Only requestSync changes the document: it runs the
syncChartData command on every chart linked to the source.
registerSource, setZoom, setPan and setMaximized change only this editor.
Every table a chart or a diagram can follow, see Table fields. Empty without chart.linkTables
getOpenInput()
The Quick Input or input table the cursor is in, see The open input. null outside one
Chart fields
Field
Value
pos
The chart's position
data
The Chart Data
spec
The Chart Spec
renderer
The Renderer the chart names
source
Its Data Source
delimiter
Its delimiter
previewUrl
Its preview URL
layout
Whether it stands alone, follows a table, or is hidden below it (setChartLayout)
tableId
The table it follows, or null
tableRead
How it reads that table, { header?, range? } with only what differs from the default, or null
Diagram fields
Field
Value
pos
The diagram's position
format
Its format
source
Its source
title
Its title
description
Its description
view
Its view
options
Its options
kind
The kind of Mermaid diagram, or null
drawable
Whether a Diagram Renderer for its format can draw the source
link
The table it is drawn from, { tableId, columns }, or null
lanes
The lanes of a diagram drawn from a table, in the order they appear
Table fields
Field
Value
pos
The table's position
tableId
Its id, once a chart follows it, or null
header
Its first row
headerCells
true when the first row is made of header cells. A first row of plain cells names the columns only when it holds no number outside the first column
charts
How many charts follow it
diagrams
How many diagrams are drawn from it
followers
Each chart and diagram that follows it, as { pos, kind: 'chart' | 'diagram' }, in document order
The open input
getOpenInput() returns { pos, view: 'chart-syntax' | 'table', type, delimiter, editing }.
editing is set when the input holds an existing chart you are changing, not a new one.
Reading a chart's data
Function
Returns
read({ pos?, format? })
A chart as text in a format, 'chart-json' by default
readGrid({ pos? })
The data as a grid of strings. Row 0 is the header
readTable({ pos? })
The data as table JSON, or null without a table node in the schema
readText({ pos? })
{ format, text } of a chart or a diagram, as an author edits it, or null (Text beside the picture)
parseFormat(format, content, type?)
{ data, spec, delimiter } parsed from content
getFormat(id)
A registered format, for its serialize
parseFormat throws an error with a message when it cannot parse the content.
What the editor can draw
Function
Returns
describeCapabilities()
Chart types ({ id, label, shape, description? }), formats, Renderers and their types, the default Renderer, sources, delimiters, trigger and styles
chartTypes
The built-in chart types and those of the chartTypes option. This is a property, not a function
canRender(spec)
Whether a registered Renderer draws the type
rendererFor(spec, preferred?)
The Renderer a chart would be drawn with
diagramRendererFor(format)
The Diagram Renderer a diagram of that format would be drawn with, or null
rulesFor(renderer)
The rules a Renderer's charts and diagrams follow, its own and those of rendererRules: { attribution?, exports? }
refresh()
Nothing. It draws every chart and diagram again. Call it after a theme change made only in CSS
Every chart and diagram that can be drawn, as files with their pos, in document order
exportDocx(options?)
A promise of a Word document with native charts and diagrams as pictures: { blob, notes }. See Word
Data Sources
Function
What it does
readSource(source)
Returns a promise of the data a source returns now. It writes nothing
requestSync(source)
Reads a source and writes the data into every chart linked to it. Returns a promise of true when it wrote data
registerSource(provider)
Adds a provider at run time and returns a function that removes it
getSource(id), listSources()
Return the registered providers
requestSync resolves to false when the read fails or no chart is linked to the source. A
failed read keeps the last snapshot and goes to onSourceError.
Zoom, pan and maximize on screen
setZoom, getZoom, setPan, getPan, getShownSize, setMaximized and getMaximized
change or read how this editor shows a chart or a diagram. They never change the document. See
View functions.
setMaximized also dispatches an empty transaction, so a UI that listens to transaction
updates. That transaction is not added to the undo history.