npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

render-dot

v0.0.7

Published

Render Graphviz .dot files to svg, png, dotx, json, jpeg, ps, etc using several graph engines, for browser, node and command line

Downloads

31

Readme

render-dot

Contents

Summary

Renders Graphviz .dot files to svg, png, and other format, using different graph engines like dot, neato, virco, etc.

Based on Graphviz [Emscripten](http://kripken.github.io/emscripten-site/ port viz.js library.

  • Supports node.js and browser JavaScript API.
  • CLI.
  • Outputs
    • Image formats: png, svg, jpeg, gif, json, ps, eps, ps2, pic, vml
    • text formats: xdot, json, xdot_json, plain, plain_ext, pov

Usage

Install

npm install render-dot

JavaScript

Render DOT code to SVG code as string:

import {renderDot} from 'render-dot'
const svgCode = await renderDot({
  input: 'digraph { a -> b; }'
})

Render DOT to PNG file:

const result = await renderDot({
  input: 'digraph { a -> b; }', 
  format: 'png'
})
writeFileSync('graph.png', result, 'binary')

Command Line

render-dot --input "some/**/*.dot" --output outputFolder
render-dot --input "digraph { a -> b; }" > tmp.svg
render-dot --input "some/**/*.dot" --output outputFolder --format gif

Options

See types.ts. Options apply both to JavaScript API and CLI.

  • input: string;: .dot code to render. For Command line, it can also be path to .dot files or glob pattern to many .dot files, relative to current dir.
  • width?: number;: Output image width.
  • height?: number;: Output image height.
  • format?: 'svg' | 'png' | 'jpeg' | 'gif' | 'json' | 'xdot' | 'plain' | 'ps' | 'eps' | 'ps2' | 'pic' | 'vml' | 'xdot_json' | 'plain_ext' | 'pov': Output format. One of: 'svg' | 'png' | 'jpeg' | 'gif' | 'json' | 'xdot' | 'plain' | 'ps'| 'eps'| 'ps2'| 'pic'| 'vml'| 'xdot_json'| 'plain_ext'| 'pov'. By default: svg.
  • engine?: Engine;: Graph layout implementation. One of : dot, circo, fdp, neato, asage, twopi, patchwork, sfdp. By default: dot.
  • quality?: number;: Quality of output image.
  • scale?: number;: Set input scale to scale. If this value is omitted, 72.0 is used. This number is used to convert the point coordinate units used in the pos attribute into inches, which is what is expected by neato and fdp. Thus, feeding the output of a graph laid out by one program into neato or fdp almost always requires this flag. Ignored if the -n flag is used.
  • yInvert?: boolean: By default, the coordinate system used in generic output formats, such as attributed dot, extended dot, plain and plain-ext, is the standard cartesian system with the origin in the lower left corner, and with increasing y coordinates as points move from bottom to top. If the -y flag is used, the coordinate system is inverted, so that increasing values of y correspond to movement from top to bottom.
  • nop?: number;: Sets no-op flag in neato. If set, neato assumes nodes have already been positioned and all nodes have a pos attribute giving the positions. It then performs an optional adjustment to remove node-node overlap, depending on the value of the overlap attribute, computes the edge layouts, depending on the value of the splines attribute, and emits the graph in the appropriate format. If num is supplied, the following actions occur:
    • num = 1 : Equivalent to -n.
    • num > 1: Use node positions as specified, with no adjustment to remove node-node overlaps, and use any edge layouts already specified by the pos attribute. neato computes an edge layout for any edge that does not have a pos attribute. As usual, edge layout is guided by the splines attribute.
  • output?: string: Folder for output files. If it doesn't exists it will be created. If none, output will be written to stdout.
  • help?: boolean: Print usage information, then exit.
  • debug?: boolean: Prints debug messages.

Status

(no browser support or test yet)

  • node.js API
  • tests
  • types

Road map

  • [x] CLI
  • [ ] Browser
  • [ ] browser tests
  • [ ] keep investigating if it's possible to input several .dot files and render them all together biding common elements.