LineChart
Defined in: charts/line.ts:36
Canvas 2D line chart with optional area fill, dots, and Bezier smoothing.
Use area: true for an area chart, or import the <Area> React component.
Pass any object array to setData(data, mapping); the mapping picks which
fields are X (labels) and Y (one or more series).
Example
Section titled “Example”import { LineChart } from '@arshad-shah/swift-chart';
const chart = new LineChart('#chart', { theme: 'midnight', smooth: true, dots: true,});
chart.setData( [ { month: 'Jan', revenue: 420, target: 400 }, { month: 'Feb', revenue: 510, target: 450 }, ], { x: 'month', y: ['revenue', 'target'] },);LineChartConfig for the full option list.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LineChart(
container,config?):LineChart
Defined in: charts/line.ts:57
Parameters
Section titled “Parameters”container
Section titled “container”string | HTMLElement
config?
Section titled “config?”LineChartConfig = {}
Returns
Section titled “Returns”LineChart
Overrides
Section titled “Overrides”Properties
Section titled “Properties”animator
Section titled “animator”animator:
Animator
Defined in: core/base.ts:63
Inherited from
Section titled “Inherited from”animProgress
Section titled “animProgress”animProgress:
number=1
Defined in: core/base.ts:74
Inherited from
Section titled “Inherited from”canvas
Section titled “canvas”canvas:
HTMLCanvasElement
Defined in: core/base.ts:60
Inherited from
Section titled “Inherited from”config
Section titled “config”config:
LineChartConfig&Required<Pick<BaseChartConfig,"title"|"animate"|"animDuration"|"animEasing"|"responsive"|"showGrid"|"showTooltip"|"showLegend"|"legendPosition"|"subtitle">> &BaseChartConfig
Defined in: charts/line.ts:37
Overrides
Section titled “Overrides”container
Section titled “container”container:
HTMLElement
Defined in: core/base.ts:51
Host element the canvas was mounted into.
Inherited from
Section titled “Inherited from”ctx:
CanvasRenderingContext2D
Defined in: core/base.ts:61
Inherited from
Section titled “Inherited from”downsampleTarget
Section titled “downsampleTarget”downsampleTarget:
number=0
Defined in: charts/line.ts:55
Downsample threshold — auto if 0
height
Section titled “height”height:
number=0
Defined in: core/base.ts:89
Inherited from
Section titled “Inherited from”hoverIndex
Section titled “hoverIndex”hoverIndex:
number=-1
Defined in: core/base.ts:65
Inherited from
Section titled “Inherited from”hoverSeriesIndex
Section titled “hoverSeriesIndex”hoverSeriesIndex:
number=-1
Defined in: core/base.ts:73
Index of the series under the cursor, or -1 when the hover is not
series-specific (e.g. a column hit on a multi-series line chart).
Charts that can pinpoint a series — bubble, scatter, network, sankey,
marimekko, treemap — set this in their _onMouse. Single-series charts
report 0 automatically via _buildClickEvent.
Inherited from
Section titled “Inherited from”padding
Section titled “padding”padding:
Padding
Defined in: core/base.ts:90
Inherited from
Section titled “Inherited from”resolved
Section titled “resolved”resolved:
ResolvedData
Defined in: core/base.ts:75
Inherited from
Section titled “Inherited from”theme:
Theme
Defined in: core/base.ts:62
Inherited from
Section titled “Inherited from”tooltip
Section titled “tooltip”tooltip:
Tooltip|null
Defined in: core/base.ts:64
Inherited from
Section titled “Inherited from”width:
number=0
Defined in: core/base.ts:88
Inherited from
Section titled “Inherited from”Accessors
Section titled “Accessors”plotArea
Section titled “plotArea”Get Signature
Section titled “Get Signature”get plotArea():
PlotArea
Defined in: core/base.ts:328
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_draw()
Section titled “_draw()”_draw():
void
Defined in: charts/line.ts:78
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”_onMouse()
Section titled “_onMouse()”_onMouse(
e):void
Defined in: charts/line.ts:61
Parameters
Section titled “Parameters”MouseEvent
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”destroy()
Section titled “destroy()”destroy():
void
Defined in: core/base.ts:461
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”resize()
Section titled “resize()”resize():
void
Defined in: core/base.ts:432
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setData()
Section titled “setData()”setData(
data,mapping?):void
Defined in: core/base.ts:350
Parameters
Section titled “Parameters”Record<string, any>[] | null | undefined
mapping?
Section titled “mapping?”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setTheme()
Section titled “setTheme()”setTheme(
theme):void
Defined in: core/base.ts:389
Switch theme. Accepts a registered theme name ('midnight', 'arctic',
'ember', 'forest', or any name passed to addTheme) or a
full Theme object — same surface that the constructor accepts
via config.theme.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”toDataURL()
Section titled “toDataURL()”toDataURL(
type?,quality?,options?):string
Defined in: core/base.ts:446
Export the current chart as a data URL.
canvas.toDataURL() always returns the backing-store bitmap, which
is DPR-multiplied — a 400×300 chart on a DPR=2 display exports as
800×600. Pass { scale: 'css' } to downscale the export to on-screen
CSS dimensions (typical for “Save as PNG” buttons); the default
'native' keeps the full backing-store resolution.
Parameters
Section titled “Parameters”string = 'image/png'
quality?
Section titled “quality?”number = 0.92
options?
Section titled “options?”scale?
Section titled “scale?”"native" | "css"
Returns
Section titled “Returns”string
Inherited from
Section titled “Inherited from”update()
Section titled “update()”update(
arg,mapping?):void
Defined in: core/base.ts:401
Polymorphic update:
- update(dataArray, mapping?) — replaces data (alias of setData).
- update(configPatch) — patches non-data config (theme, title, padding, etc.).
Parameters
Section titled “Parameters”Record<string, any>[] | Partial<BaseChartConfig>
mapping?
Section titled “mapping?”Returns
Section titled “Returns”void