Socket
Book a DemoInstallSign in
Socket

gl-axes2d

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-axes2d

2D plot axes element

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

gl-plot2d

A WebGL based 2D rendering for large plots.

Example

Still messy here...

Install

With npm,

npm i gl-plot2d

API

Constructor

var plot = require('gl-plot2d')(options)

Constructs a new gl-plot2d object.

  • options is an object containing parameters for constructing the plot

Options can contain the following parameters,

Required properties
PropertyDescription
glA WebGLRenderingContext object, into which the plot is drawn
pixelRatioA scale factor which is applied to pixel coordinates
screenBoxBounds on the plot within the WebGL context
viewBoxPixel coordinates where the plot is drawn
dataBoxData coordinates for the view of the plot

Note: Coordinates for screenBox, viewBox, dataBox, etc. are given by 4-tuples of bounding box coordinates in the form [xmin, ymin, xmax, ymax].

Border and background colors
PropertyDescriptionDefault
borderColorBorder color as a normalized RGBA tuple[0,0,0,0]
backgroundColorBackground color[0,0,0,0]
borderLineEnableToggle drawing lines for left,bottom,right,top of border[true,true,true,true]
borderLineWidthWidth of border lines[2,2,2,2]
borderLineColorColor of border lines[[0,0,0,1], [0,0,0,1], [0,0,0,1], [0,0,0,1]]

Note: For properties which are specified per-screen direction like borderLineEnable etc., the components are always arranged in the order left,bottom,right,top.

Ticks
PropertyDescriptionDefault
ticksSee note below[[], []]
tickEnableTurn on display of ticks for a given axis[true, true, true, true]
tickPadDistance between tick text and tick marks[15,15,15,15]
tickAngleAngle to draw ticks at[0,0,0,0]
tickColorColor of ticks[[0,0,0,1], [0,0,0,1], [0,0,0,1], [0,0,0,1]]
tickMarkWidthTick marks[0,0,0,0]
tickMarkLength[0,0,0,0]

Note: Ticks are encoded as an array of objects, each with the following properties:

  • x The data coordinate of the tick
  • text The text associated to the tict mark
  • font The font for the text
  • size The font size for the tick
Labels
PropertyDescriptionDefault
labelsThe label text for each axis['x', 'y']
labelEnableTurns on/off rendering for the labels on the left,bottom,top,right[true, true, true, true]
labelAngleAngle to draw label text[0,Math.PI/2,0,3.0*Math.PI/2]
labelPadPadding for labels in pixel coordinates[15,15,15,15]
labelSizeSize of labels in pixels[12, 12]
labelFontFont for labels['sans-serif', 'sans-serif']
labelColorColor of labels[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]
Title
PropertyDescriptionDefault
titleTitle text''
titleEnableToggles title renderingtrue
titleCenterPixel coordinates for center of title[0.5*(viewBox[0]+viewBox[2]), viewBox[3] - 40]
titleAngleAngle to draw title text0
titleColorColor of title[0,0,0,1]
titleFontTitle font'sans-serif'
titleSizeTitle font size18
Grid lines
PropertyDescriptionDefault
gridLineEnableTurns on grid lines per axis[true, true]
gridLineColorGrid line color[[0,0,0,0.5], [0,0,0,0.5]]
gridLineWidthWidth of grid lines[1, 1]
zeroLineEnableToggle rendering of zero line[true, true]
zeroLineWidthWidth of zero line in pixels[2, 2]
zeroLineColorColor of zero line[[0,0,0,1], [0,0,0,1]]

Methods

plot.update(options)

Updates the properties of the plot.

  • options is an option structure, as described in the constructor

plot.setScreenBox(box)

Changes the screen box of the plot

plot.setViewBox(box)

Changes the view box

plot.setDataBox(box)

Changes the view box

plot.draw()

Redraws the plot. Call this once per requestAnimationFrame()

plot.dispose()

Destroy plot and release all associated resources

License

(c) Mikola Lysenko. MIT License

Supported by plot.ly

Keywords

2d

FAQs

Package last updated on 22 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts