Class CartesianCanvasPlot

Simple plotting of cartesian values.

// Create the data set
const ds = new Plot.DataSet();

// Create plotter, providing a CANVAS element and the dataset
const p = new Plot.CartesianCanvasPlot(`#plot`, ds);

// Add data
ds.add({ x:1, y:1 });

// Request it to draw the current data
p.draw();

Series

// Add a value to the `alpha` series
ds.add({x:1,y:1}, `alpha`);

Series can have metadata associated with it in the DataSet

// Use 'pink' by default for the series 'alpha'
ds.setMeta(`alpha`, { colour: `pink` });

Constructors

Properties

actualDataRange: RectPositioned = Rects.EmptyPositioned
axisRounder: ((v: number) => number) = ...
helper: CanvasHelper
margin: number
overlayLines: (Line & LineStyle)[] = []

List of lines to draw after drawing everything else. Lines are given in value-coordinate space

renderArea: Point & Rect & {
    dimensionMin: number;
} = ...
visibleRange: RectPositioned = Rects.PlaceholderPositioned
whiskerLength: number

Methods

  • Returns Point & Rect & {
        dimensionMin: number;
    }

  • Returns void

  • Draws a line in value-coordinate space

    Parameters

    • line: Line
    • colour: string
    • width: number

    Returns void

  • When range is auto, returns the range of the data Otherwise returns the user-provided range.

    Returns PointMinMax

  • Positions an element at the viewport location of data point. Ensure the element has position:absolute set.

    Parameters

    • data: Point
    • elOrQuery: string | HTMLElement
    • by: "middle" | "top-left" = ...
    • relativeToQuery: string | HTMLElement

    Returns void

  • Converts a point in pixel coordinates to a value. Useful for converting from user input coordinates.

    Parameters

    Returns Point

  • Parameters

    Returns void

  • Parameters

    Returns {
        x: number;
        y: number;
    }

    • x: number
    • y: number
  • Converts a point in data space to viewport space

    Parameters

    Returns Point