Canvas-based data plotter.

const p = new Plot(document.getElementById(`myCanvas`), opts);

// Plot 1-5 as series test'
p.createSeries(`test`, `array`, [1,2,3,4,5]);

// Create a streaming series, add a random number
const s = p.createSeries(`test2`, `stream`);
s.add(Math.random());

createSeries returns the Series instance with properties for fine-tuning

For simple usage, use plot(someData) which automatically creates series for the properties of an object.

Hierarchy (view full)

Constructors

Properties

_layoutPosition: undefined | Point
_measuredSize: undefined | Rect
_needsDrawing: boolean = true
_needsLayoutX: boolean = true
_needsMeasuring: boolean = true
_parent: undefined | Box
_ready: boolean = true
axisStrokeColour: string
axisStrokeWidth: number
axisTextColour: string
axisX: AxisX
axisY: AxisY
bounds: undefined | RectPositioned
canvasRegion: RectPositioned = RectsPlaceholderPositioned

Rectangle Box occupies in canvas/etc

children: Box[] = []
debugHue: number = ...
debugLayout: boolean = false
defaultSeriesOpts?: SeriesOpts
id: string
legend: Legend
legendTextColour: string
plotArea: PlotArea
scaling: ScalingOption
series: Map<string, Visual.Plot2.Series>
takesSpaceWhenInvisible: boolean = false

Accessors

  • get desiredRegion(): undefined | BoxRect
  • Gets the box's desired region, or undefined

    Returns undefined | BoxRect

  • set desiredRegion(v): void
  • Sets the box's desired region. Calls onLayoutNeeded()

    Parameters

    Returns void

  • get frozen(): boolean
  • Returns boolean

  • set frozen(v): void
  • Parameters

    • v: boolean

    Returns void

  • get root(): Box
  • Returns the root box

    Returns Box

  • get seriesLength(): number
  • Returns number

  • get visible(): boolean
  • Gets visible state

    Returns boolean

  • set visible(v): void
  • Sets visible state

    Parameters

    • v: boolean

    Returns void

Methods

  • Called if this is the parent Box

    Parameters

    • element: HTMLElement

    Returns void

  • Removes all series, plot, legend and axis data.

    Returns void

  • Calls 'clear()' on each of the series

    Returns void

  • Debug log from this box context

    Parameters

    • m: any

    Returns void

  • Parameters

    • ctx: CanvasRenderingContext2D
    • force: boolean = false

    Returns void

  • Draw this object

    Parameters

    • _ctx: CanvasRenderingContext2D

    Returns void

  • Returns Generator<never, IterableIterator<[number, Box]>, unknown>

  • Returns true if box is a child

    Parameters

    Returns boolean

  • Calls notifyChildLayoutNeeded

    Parameters

    • reason: string

    Returns void

  • Applies actual size, returning true if size is different than before

    1. Sets _needsLayout to false.
    2. Sets visual to m
    3. Calls measureApply on each child
    4. If there's a change or force, sets needsDrawing to true, and notifies root of measureApplied

    Parameters

    Returns boolean

  • Measure the box

    1. Uses desired rectangle, if possible
    2. Otherwise uses parent's size

    Parameters

    Returns string | Rect

  • Start of measuring

    1. Keeps track of measurements in opts.measurements
    2. If this box takes space 2.1. Measure itself if needed 2.2. Use size
    3. Calls measureStart on each child

    Parameters

    Returns undefined | Measurement

    Measurement

  • Sends a message to all child boxes.

    This first calls onNotify on this instance, before calling notify() on each child.

    Parameters

    • message: string
    • source: Box

    Returns void

  • Notification a child box has been added

    Throws if

    • child has parent as its own child
    • child is same as this
    • child is already child of this

    Parameters

    Returns void

  • Handles a received message

    Parameters

    • _message: string
    • _source: Box

    Returns void

  • Handler when pointer moves within our region

    Parameters

    Returns void

  • Plots a simple object, eg { x: 10, y: 20, z: 300 } Series are automatically created for each property of o

    Be sure to call update() to visually refresh.

    Parameters

    • o: any

    Returns void

  • Sets _ready to ready. If includeChildren is true, setReady is called on each child

    Parameters

    • ready: boolean
    • includeChildren: boolean = false

    Returns void

  • Performs recalculations and drawing as necessary If nothing needs to happen, function returns.

    Parameters

    • Optionalctx: CanvasRenderingContext2D
    • force: boolean = false

      Force update

    Returns void

  • Parameters

    • _measureChanged: boolean
    • _layoutChanged: boolean

    Returns void