Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gl-plot2d

Package Overview
Dependencies
Maintainers
18
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-plot2d

2D webgl plots

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
27K
decreased by-6.51%
Maintainers
18
Weekly downloads
 
Created
Source

gl-plot2d

A rendering engine for drawing huge 2D plots using WebGL.

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 tick labels[[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]
tickMarkColor[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1]]

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.draw()

Redraws the plot. Call this once per requestAnimationFrame()

plot.pick(x, y)

Finds the current data point highlighted by the user.

  • x,y are the coordinates of the mouse in pixel coordinates

Returns If the user is selecting a data point, then returns the current data point selected by the user. Otherwise, returns null

plot.dispose()

Destroy plot and release all associated resources

License

(c) Mikola Lysenko. MIT License

Supported by plot.ly

Keywords

FAQs

Package last updated on 23 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc