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

@stoqey/gnuplot

v0.0.3

Published

Node gnuplot

Downloads

6

Readme

gnuplot for node

npm TypeScript compatible

@stoqey/gnuplot is an easy to use node module to draw charts using gnuplot and ps2pdf. This module is based on Richard Meadows's node-plotter

Installation

Prerequisites:

# ubuntu
sudo apt-get install gnuplot

# alpine
apk add gnuplot

# mac
brew install gnuplot

To install package, just run:

npm install @stoqey/gnuplot

Usage

import plot from '@stoqey/gnuplot'

// with callback
plot({
	data:		[ 3, 1, 2, 3, 4 ],
	filename:	'output.png',
	finish: (error) => {

	}
});

// As promise
const plotted = await plot({
	data: [3, 1, 2, 3, 4],
	filename: 'output1.png',
});

Output format

This defaults to .png but specifing format: svg changes the output to .svg and format: pdf changes the output format to .pdf.

import plot from '@stoqey/gnuplot'

plot({
	data:		[ 3, 1, 2, 3, 4 ],
	filename:	'output.svg',
	format:		'svg'
});

Formatting

The following properties can be used:

  • title : Sets the title of the graph
  • xlabel : Sets the label on the x axis of the graph
  • ylabel : Sets the label on the y axis of the graph
  • logscale : Makes the y axis of the graph appear in a log scale
  • style : The style of the lines on the graph. Possibilites include lines (default), points and linespoints
  • nokey : Disables the graph key
  • hideSeriesTitle: Indicates if plot should include legend
  • margin: Sets margin if needed
  • xRange: Sets max and min values for the X axis
  • yRange: Sets max and min values for the Y axis
  • decimalsign: Specifies a custom decimal sign
  • yFormat: Specifies how to format values on the Y axis
  • font: Specify a custom font
  • fontSize: Font size
  • titleSize: Title font size
  • width: Plot width
  • height: Plot height
  • locale: Locale code (run 'set locale' for the exact value)

The following example shows these in use:

plot({
	title:		'example',
	data:		{ 't1' : { 1357162672: 22.2, 1357162782: 23, 1357162892: 24 } },
	time:		'hours',
	style:		'line',
	filename:	'test/output14.png',
	format:		'png',
	decimalsign: ',',
	yFormat: '%.2f USD',
	hideSeriesTitle: true,
	xlabel:		'Time',
	ylabel:		'Price',
	margin: 	{
		left: 10,
		right: 3,
		top: 3,
		bottom: 4
	},
	xRotate: {
		value: 45,
		yOffset: -1.5,
		xOffset: -2
	},
	hideSeriesTitle: true,
	xRange: {
		min: 0,
		max: 100
	}
});

Specifing X and Y values

plot({
	data:		{ 'line' : { 1: 5, 5: 6 } },
	filename:	'output.png'
});

Instead of specifing an array for data, you can specify an object with a named series inside.

Multiple Series

plot({
	data:		{ 'tick' : [ 3, 1, 2, 3, 4 ], 'line' : { 1: 5, 5: 6 } },
	filename:	'output.png'
});

Time Formatting

plot({
	data:		{ 'temperature' :
			{ 1357162672: 22, 1357162782: 23, 1357162892: 24 } },
	time:		'hours',
	filename:	'output.png'
});

The x axis can be formatted as a time series if the x values are given as a unix time. The time property can be specified with the gnuplot time format.

Other options

The options object might additionally contain the following:

Option | Description | Example -------|-------------|--------- exec | Arguments for the gnuplot process | options.exec = { cwd : '/home/user/images' }; finish | Callback executed when the gnuplot process finishes | options.finish = function(){ Console.log('Success!'); };