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

skyrta

v0.1.8

Published

A wrapper around popular graphing tools (GraphViz, SvgBobRus) to convert text based diagrams to SVG.

Downloads

2,912

Readme

skyrta

A Node.js wrapper around popular graphing tools to generate graphs.

npm version Build Status Maintainability Dependencies

A wrapper around some popular graph tools to generate diagrams from their text representation.

This package currently supports:

This package is simple in that it passes in the input provided directly over stdin to the appropriate process and returns the generated SVG.

Usage

General

npm install skyrta --save

And then:

const skyrta = require('skyrta');
let svg = skyrta.generate('bob', '----->');

To get the raw string data you can either call toString() on the object or use the value property:

let svg = skyrta.generate('bob', '----->').toString();

or

let svg = skyrta.generate('bob', '----->').value;

Some diagramming tools like GraphViz outputs full SVG, including DOCTYPE and XML tags. To strip these for embedding purposes in HTML you can use the toEmbed function which will strip out anything outside of the <svg> tag.

let svg = skyrta.generate('bob', '----->').toEmbed();

Options

Skyrta supports plugin specific options. You can pass them directly to the generate function:

let svg = skyrta.generate('bob', '----->', {
    // Your options here
}).toEmbed();

Global options: * variableSize: Boolean - optionally strips width and height attributes from the SVG tag. Default: true.

You can find the specific options for each diagram type below.

Diagrams

SvgBobRus diagrams

This package expects svgbob_cli to available in the system path. Installation:

cargo install svgbob_cli

You can find specific instructions on the repo page.

let svg = skyrta.generate('bob', '*----->').toEmbed();

An input like this

Bob markup

will provide the following (rendered) SVG diagram:

Bob diagram

Options

| Option | Translates to | | ----------- | -------------- | | fontFamily | --font-family | | fontSize | --font-size | | scale | --scale | | strokeWidth | --stroke-width |

Please see the official documentation for detailed descriptions on these options. Example:

{
    fontFamily: "arial"
    fontSize: 14,
    scale: 1,
    strokeWidth: 2
}

Graphviz

Graphviz can be installed in most cases via your package manager. See the download page for manual downloads and installation instruction instructions.

A simple graph

Graphviz markup

will provide the following (rendered) SVG diagram:

Graphviz output

Options

| Option | Translates to | | ------------------- | ------------- | | graphAttributes: {} | -Gname=val | | nodeAttributes: {} | -Nname=val | | edgeAttributes: {} | -Ename=val | | scale | -s[scale] | | engine | -Kv |

Please see the official documentation for possible values of these parameters.

graphAttributes, nodeAttributes, and edgeAttributes are multi-valued options. In other words, for each key a -G, -N, or E option will be passed to the dot executable.

For example, to set the default styles for arrowheads to empty you can provide the following options:

edgeAttributes: {
   'arrowtail': 'empty',
   'arrowhead': 'empty'
}

A list of possible attributes can be found here.

Mermaid

To render Mermaid graphs you need to install both the mermaid and the cli packages:

npm install mermaid mermaid.cli --save

Note the . in the cli package name - the package with a - that shall not be named here has been deprecated.

A sample flowchart from the main Mermaid repository:

Graphviz markup

will provide the following (rendered) SVG diagram:

Mermaid output

Options

| Option | Translates to | | ------------------- | ------------------- | | theme | theme | | width | width | | height | height | | backgroundColor | backgroundColor | | configFile | configFile | | cssFile | cssFile | | puppeteerConfigFile | puppeteerConfigFile |

It's pretty much a one to one mapping. Please see the cli documentation for possible values of these parameters.

Demo

Skyrta is used in the gatsby-remark-draw plugin to convert code blocks in Markdown to inline SVG. You can see some samples in action here.

Version history

1.5.

Added support for Mermaid graphs.

1.4.

Added options to pass to the executable rendering the graph.

1.3

SVG returned in wrapper class with the toEmbed() function to strip excess XML for HTML embedding purposes.

TODO

  • ~~Options support~~
  • CLI
  • Mermaid support
  • PlantUML support