Appearance
Chart API
Methods for a single chart. Obtain a handle from the Widget API:
typescript
const chart = chartspire.getChart({ id: 'chart1' })
const active = chartspire.getActiveChart()Use { id: 'chart1' }, { id: 'chart2' }, and so on, or values returned by getVisibleChartIds(). See Widget API — Charts and multichart for how chart IDs are assigned.
Returns null until that chart is mounted.
typescript
chartspire.getChart({ id: 'chart2' })?.createOverlay('segment')
chartspire.getActiveChart()?.zoomAtDataIndex(1.2, 100)
chartspire.getVisibleChartIds().forEach((id) => {
chartspire.getChart(id)?.scrollToRealTime()
})Locale and timezone are configured on the Widget API. For styling, use Widget API setCustomStyles (widget-wide, persists across theme switches).
Undocumented methods from the underlying chart engine are intentionally unavailable on ChartApi. Only the methods on this page are part of the public Chart API.
Symbol and period
setSymbol(symbol)
Set the chart symbol. Pass a Symbol object.
typescript
(symbol: Symbol) => voidReturns — void
typescript
chartspire.getChart({ id: 'chart1' })?.setSymbol({
symbol: 'BTCUSDT',
type: 'crypto',
exchange: 'binance',
})getSymbol()
Get the chart symbol.
typescript
() => Symbol | nullReturns — Current Symbol, or null
setPeriod(period)
Set the chart period.
typescript
(period: Period) => voidParameters
periodtype—'second'|'minute'|'hour'|'day'|'week'|'month'|'year'span— Multiplier for the period type
Returns — void
typescript
chartspire.getActiveChart()?.setPeriod({ span: 15, type: 'minute' })getPeriod()
Get the chart period.
typescript
() => Period | nullReturns — Current Period, or null
Scroll and zoom
scrollByDistance(distance, animationDuration?)
Scroll by pixel distance.
typescript
(distance: number, animationDuration?: number) => voidParameters
distance— Pixel distanceanimationDuration— Animation duration in milliseconds (optional)
Returns — void
scrollToRealTime(animationDuration?)
Scroll to the latest bar.
typescript
(animationDuration?: number) => voidReturns — void
typescript
chartspire.getActiveChart()?.scrollToRealTime()scrollToDataIndex(dataIndex, animationDuration?)
Scroll to a data index.
typescript
(dataIndex: number, animationDuration?: number) => voidParameters
dataIndex— Target data indexanimationDuration— Animation duration in milliseconds (optional)
Returns — void
scrollToTimestamp(timestamp, animationDuration?)
Scroll to a timestamp.
typescript
(timestamp: number, animationDuration?: number) => voidParameters
timestamp— Target timestampanimationDuration— Animation duration in milliseconds (optional)
Returns — void
zoomAtCoordinate(scale, coordinate?, animationDuration?)
Zoom at a pixel coordinate.
typescript
(
scale: number,
coordinate?: { x: number, y: number },
animationDuration?: number
) => voidParameters
scale— Zoom scalecoordinate— Pixel coordinate (optional)animationDuration— Animation duration in milliseconds (optional)
Returns — void
zoomAtDataIndex(scale, dataIndex, animationDuration?)
Zoom at a data index.
typescript
(scale: number, dataIndex: number, animationDuration?: number) => voidParameters
scale— Zoom scaledataIndex— Target data indexanimationDuration— Animation duration in milliseconds (optional)
Returns — void
typescript
chartspire.getActiveChart()?.zoomAtDataIndex(1.2, 100)zoomAtTimestamp(scale, timestamp, animationDuration?)
Zoom at a timestamp.
typescript
(scale: number, timestamp: number, animationDuration?: number) => voidParameters
scale— Zoom scaletimestamp— Target timestampanimationDuration— Animation duration in milliseconds (optional)
Returns — void
Indicators
createIndicator(indicator, isStack?)
Add an indicator to the chart. The indicator name must already be registered (built-in, or via Extension API registerIndicator).
typescript
(indicator: string | IndicatorCreate, isStack?: boolean) => string | nullSee IndicatorCreate for the config object shape.
Parameters
indicator— Indicator name, orIndicatorCreateconfigisStack— Whether to stack on an existing pane
Returns — Indicator id string, or null
typescript
chartspire.getActiveChart()?.createIndicator('MA')
chartspire.getActiveChart()?.createIndicator({
name: 'MA',
calcParams: [10, 30],
visible: true,
})getIndicators(filter?)
Get indicators on the chart.
typescript
(filter?: IndicatorFilter) => Indicator[]See IndicatorFilter.
Parameters
filter— Optional match by id, name, and/or pane
Returns — Indicator[]
overrideIndicator(indicator)
Update an indicator on the chart. Pass a partial IndicatorCreate — only the fields you want to change. Prefer id to target a specific instance.
typescript
(indicator: Partial<IndicatorCreate>) => booleanReturns — boolean — Whether an indicator was updated
removeIndicator(filter?)
Remove indicators on the chart.
typescript
(filter?: IndicatorFilter) => booleanSee IndicatorFilter.
Parameters
filter— Optional match by id, name, and/or pane. Omit to remove matching set per implementation defaults.
Returns — boolean — Whether an indicator was removed
Overlays
createOverlay(value)
Create an overlay / drawing on the chart.
typescript
(value: string | OverlayCreate | Array<string | OverlayCreate>) => string | null | Array<string | null>See OverlayCreate.
Returns — Overlay id(s), or null
typescript
chartspire.getChart({ id: 'chart1' })?.createOverlay('segment')getOverlays(filter?)
Get overlays on the chart.
typescript
(filter?: OverlayFilter) => Overlay[]See OverlayFilter.
Parameters
filter— Optional match by id, name, group, and/or pane
Returns — Overlay[]
overrideOverlay(overlay)
Update an overlay on the chart. Pass a partial OverlayCreate — only the fields you want to change. Prefer id to target a specific instance.
typescript
(overlay: Partial<OverlayCreate>) => booleanReturns — boolean — Whether an overlay was updated
removeOverlay(filter?)
Remove overlays on the chart.
typescript
(filter?: OverlayFilter) => booleanSee OverlayFilter.
Parameters
filter— Optional match by id, name, group, and/or pane
Returns — boolean — Whether an overlay was removed
Coordinates and export
convertToPixel(value, finder?)
Convert data values to pixel coordinates.
typescript
(
value: {
dataIndex?: number
timestamp?: number
value?: number
} | Array<{
dataIndex?: number
timestamp?: number
value?: number
}>,
finder?: {
paneId?: string
absolute?: boolean
}
) => { x?: number, y?: number } | Array<{ x?: number, y?: number }>Parameters
value— Point or points to convert. If bothdataIndexandtimestampexist, conversion uses the index.finderpaneId— Pane idabsolute— Absolute y-axis coordinates whentrue
Returns — Coordinate or coordinate array
convertFromPixel(coordinate, finder?)
Convert pixel coordinates to data values.
typescript
(
coordinate: {
x?: number
y?: number
} | Array<{
x?: number
y?: number
}>,
finder?: {
paneId?: string
absolute?: boolean
}
) => {
dataIndex?: number
timestamp?: number
value?: number
} | Array<{
dataIndex?: number
timestamp?: number
value?: number
}>Parameters
coordinate— Pixel coordinate or coordinatesfinderpaneId— Pane idabsolute— Absolute y-axis coordinates whentrue
Returns — Point or point array
getConvertPictureUrl(includeOverlay?, type?, backgroundColor?)
Export the chart as an image data URL.
typescript
(
includeOverlay?: boolean,
type?: 'png' | 'jpeg' | 'bmp',
backgroundColor?: string
) => stringParameters
includeOverlay— Include overlays whentruetype— Image typebackgroundColor— Background color
Returns — Data URL string
typescript
const url = chartspire.getActiveChart()?.getConvertPictureUrl(true, 'png')Related
- Widget API — theme, locale, timezone,
getChart/getActiveChart - Extension API — register custom overlays and indicators
- Widget API — constructor options