Plotter.js

A JavaScript helper to plot data.

View the Project on GitHub

Diagram class

Home

This article describes the Diagram class.

This article is incomplete.

Constructor

Creates a new diagram that operates on a canvas.

Syntax:

const diagram = new Plotter.Diagram(HTMLCanvasElement canvas)

Arguments:

Returns:

Instance properties

All properties have corresponding getters and setters which you can use to read or write the properties’ values. The setters return the instance of the diagram itself.

Instance methods

Along with the getters and setters, the Diagram class has the following methods:

getCanvas

Returns the diagram’s canvas element.

Syntax:

HTMLCanvasElement diagram.getCanvas()

Arguments: none.

Returns:

getCanvasContext

Returns the diagram’s canvas rendering context.

Syntax:

CanvasRenderingContext2D diagram.getCanvasContext()

Arguments: none.

Returns:

center

Centers the chart in the canvas by setting the diagram’s positionX and positionY property.

Syntax:

Diagram diagram.center()

Arguments: none.

Returns:

drawBarChart

Draws a bar chart on the canvas.

Syntax:

Diagram diagram.drawBarChart([PointList pointList = diagram.pointList])

Arguments:

Returns:

drawLineChart

Draws a line chart on the canvas.

Syntax:

Diagram diagram.drawLineChart([PointList pointList = diagram.pointList])

Arguments:

Returns:

drawXAxis

Draws a x axis on the baseline of the canvas (the line where points that have a y value of zero are drawn).

Syntax:

Diagram diagram.drawXAxis([string name = ''])

Arguments:

Returns:

drawYAxis

Draws a y axis on the left side of the canvas (the line where points that have a x value of zero are drawn).

Syntax:

Diagram diagram.drawYAxis([string name = ''])

Arguments:

Returns: