Socket
Socket
Sign inDemoInstall

graphology-canvas

Package Overview
Dependencies
68
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graphology-canvas

Canvas rendering routines for graphology.


Version published
Weekly downloads
124
increased by129.63%
Maintainers
2
Created
Weekly downloads
 

Changelog

Source

0.3.0

  • Adding merge flags to import methods.

Readme

Source

Build Status

Graphology Canvas

Canvas rendering routines for graphology.

Installation

npm install graphology-canvas

If you need to use this package's functions in node, you will also need to install node-canvas thusly:

npm install canvas

If you experience any issue when installing the libray check that you have the required dependencies as listed here.

Usage

Rendering a graph in an arbitrary canvas context

import {render} from 'graphology-canvas';

render(graph, context, settings);

Rendering asynchronously to avoid freezing main thread

import {renderAsync} from 'graphology-canvas';

renderAsync(graph, context, settings, function() {
  console.log('Done!');
});

Rendering a graph to PNG in node

import {renderToPNG} from 'graphology-canvas/node';

renderToPNG(graph, './graph.png', () => console.log('Done!'));
renderToPNG(graph, './graph.png', settings, () => console.log('Done!'));

Settings

  • width ?number [2048]: width of the canvas. Will be the same as height if not provided.
  • height ?number [2048]: height of the canvas. Will be the same as width if not provided.
  • margin ?number [20]: margin to keep around the drawing.
  • nodes ?object: node-related settings:
    • defaultColor ?string [#999]: default color for nodes.
    • reducer ?function: reducer fonction for nodes taking the rendering settings, the node key and its attributes and tasked to return rendering info such as color, size etc.
  • edges ?object: node-related settings:
    • defaultColor ?string [#999]: default color for edges.
    • reducer ?function: reducer fonction for edges taking the rendering settings, the node key and its attributes and tasked to return rendering info such as color, size etc.

Async Settings

  • batchSize ?number [500]: number of items to render on canvas on each animation frame, increase or decrease to tweak performance vs. UI availability.

Keywords

FAQs

Last updated on 11 Jan 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc