Creates the SVG chart renderer for one store. All mounted charts share one
view cache. A chart redraws after a chart-change event names it, or after a
resize, at most once per animation frame. Scrolling never redraws a chart.
Examples
function showChart ( store : Store , host : HTMLElement , chart : ChartRef ) {
Declaration
Referenced by
Workspace packages depending on @sheetwrite/charts
@sheetwrite/docs-startdependency
Public exports naming createChartRenderer
function createChartRenderer(store: Store): ChartRenderer function createChartRenderer ( store : Store ) : ChartRenderer function createChartRenderer (
store : Store ,
) : ChartRenderer Creates the SVG chart renderer for one store. All mounted charts share one view cache. A chart redraws after a chart-change event names it, or after a resize, at most once per animation frame. Scrolling never redraws a chart. Example import { createChartRenderer } from "@sheetwrite/charts" ;
import type { ChartRef, Store } from "@sheetwrite/core" ;
function showChart ( store : Store , host : HTMLElement , chart : ChartRef ) {
const renderer = createChartRenderer (store);
const mounted = renderer. mount (host, chart, { width: 320 , height: 200 });
return () => {
mounted. dispose ();
renderer. dispose ();
};
} API reference → interface ChartRef interface ChartRef interface ChartRef Stable identity of one chart: the sheet that owns it and its ID on that sheet. API reference → interface Store interface Store interface Store Columnar workbook storage, query, transaction, and subscription contract. API reference → function showChart(store: Store, host: HTMLElement, chart: ChartRef): () => void function showChart (
store : Store ,
host : HTMLElement ,
chart : ChartRef ,
) : () => void function showChart (
store : Store ,
host : HTMLElement ,
chart : ChartRef ,
) : () => void interface HTMLElement interface HTMLElement interface HTMLElement The HTMLElement interface represents any HTML element. MDN Reference const renderer: ChartRenderer const renderer : ChartRenderer const renderer : ChartRenderer Name of a registered custom cell renderer (see Grid.defineCellRenderer). API reference → store: Store let store : Store let store : Store API reference → const mounted: MountedChart const mounted : MountedChart const mounted : MountedChart API reference → ChartRenderer.mount(host: HTMLElement, chart: ChartRef, size: {
width: number;
height: number;
}): MountedChart ChartRenderer. mount (host: HTMLElement, chart: ChartRef, size: {
width: number;
height: number;
}): MountedChart ChartRenderer. mount (host: HTMLElement, chart: ChartRef, size: {
width: number;
height: number;
}): MountedChart host is an empty element that core owns, positions and clips. API reference → host: HTMLElement let host : HTMLElement let host : HTMLElement chart: ChartRef let chart : ChartRef let chart : ChartRef API reference → width: number let width : number let width : number Unzoomed column width in CSS pixels. API reference → height: number let height : number let height : number Host height in CSS pixels for numbers or any CSS length string. API reference → MountedChart.dispose(): void MountedChart. dispose (): void MountedChart. dispose (): void Stop observing the store and release cached views. API reference → ChartRenderer.dispose(): void ChartRenderer. dispose (): void ChartRenderer. dispose (): void Stop observing the store and release cached views. API reference → interface Store {
getWorkbook(): Workbook;
getCell(addr: CellAddress): ResolvedCell;
getFormula(addr: CellAddress): string | null;
getSpillAnchor(addr: CellAddress): CellAddress | null;
getRefTarget(addr: CellAddress): CellAddress | null;
recalculateVolatile(now?: Date): void;
getVisibleWindow(
sheet: SheetId,
rows: { start: number; end: number },
cols: readonly number[],
): VisibleWindowView;
getDataWindow?(
sheet: SheetId,
rows: { start: number; end: number },
// … 27 more lines — see the API reference
} interface Store {
getWorkbook () : Workbook ;
getCell ( addr : CellAddress ) : ResolvedCell ;
getFormula ( addr : CellAddress ) : string | null ;
getSpillAnchor ( addr : CellAddress ) : CellAddress | null ;
getRefTarget ( addr : CellAddress ) : CellAddress | null ;
recalculateVolatile ( now ?: Date ) : void ;
getVisibleWindow (
sheet : SheetId ,
rows : { start : number ; end : number },
cols : readonly number [],
) : VisibleWindowView ;
getDataWindow ? (
sheet : SheetId ,
rows : { start : number ; end : number },
// … 27 more lines — see the API reference
} interface Store {
getWorkbook () : Workbook ;
getCell (
addr : CellAddress ,
) : ResolvedCell ;
getFormula (
addr : CellAddress ,
) : string | null ;
getSpillAnchor (
addr : CellAddress ,
) : CellAddress | null ;
getRefTarget (
addr : CellAddress ,
) : CellAddress | null ;
recalculateVolatile (
now ?: Date ,
) : void ;
getVisibleWindow (
sheet : SheetId ,
// … 60 more lines — see the API reference
} Columnar workbook storage, query, transaction, and subscription contract. API reference → interface ChartRenderer {
mount(
host: HTMLElement,
chart: ChartRef,
size: { width: number; height: number },
): MountedChart;
dispose(): void;
} interface ChartRenderer {
mount (
host : HTMLElement ,
chart : ChartRef ,
size : { width : number ; height : number },
) : MountedChart ;
dispose () : void ;
} interface ChartRenderer {
mount (
host : HTMLElement ,
chart : ChartRef ,
size : {
width : number ;
height : number ;
},
) : MountedChart ;
dispose () : void ;
} Draws charts into host elements that the grid's object layer owns. API reference →