Skip to content

CanvasLinePlot

Overview

CanvasLinePlot renders a {Array.<Vector2|null>} dataSet on a canvas that is managed by a ChartCanvasNode. Typically, it is preferable to use LinePlot, but this alternative is provided for cases where canvas must be used for performance. Like LinePlot, null values are skipped, and allow you to create gaps in a plot. @see LinePlot

@author Sam Reid (PhET Interactive Simulations)

Class CanvasLinePlot

import { CanvasLinePlot } from 'scenerystack/bamboo';

Constructor

new CanvasLinePlot( chartTransform : ChartTransform, dataSet : Array<Vector2 | null>, providedOptions? : CanvasLinePlotOptions )

Instance Methods

setStroke( stroke : Color | string | null )

Sets the stroke. @param stroke - If you call setStroke, you are responsible for calling update on the associated ChartCanvasNode(s).

dispose()

setDataSet( dataSet : Vector2[] )

Sets dataSet. You are responsible for calling update on the associated ChartCanvasNode(s).

paintCanvas( context : CanvasRenderingContext2D )

Intended to be called by ChartCanvasNode.

Instance Properties

dataSet : ( Vector2 | null )[]

If you change this directly, you are responsible for calling update on the corresponding ChartCanvasNode.

lineWidth : number

If you change this directly, you are responsible for calling update on the corresponding ChartCanvasNode.

lineDash : number[]

If you change this directly, you are responsible for calling update on the corresponding ChartCanvasNode.

Type CanvasLinePlotOptions

import type { CanvasLinePlotOptions } from 'scenerystack/bamboo';

Source Code

See the source for CanvasLinePlot.ts in the bamboo repository.