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

data-forge-plot

v1.0.2

Published

Plotting API for use with Data-Forge.

Downloads

230

Readme

data-forge-plot

The forgiving plotting API designed for use with Data-Forge.

Data-Forge Plot is now a simple wrapper for the Plot library.

Use Data-Forge Plot to quickly and conveniently render charts from your data in JavaScript or TypeScript. It is an abstraction layer that connects Data-Forge with JavaScript visualization libraries so that it's easy to plot charts from your data.

Why not do your data wrangling, analysis and visualization entirely in JavaScript? To support my effort please buy or help promote my book Data Wrangling with JavaScript.

Or check out my blog: The Data Wrangler.

Do your prototyping and exploratory data analysis in JavaScript with Data-Forge Notebook.

Please join the conversation on Gitter

Breaking changes

As of version 1.0.0 Data-Forge Plot has been gutted and reimplimented in terms of the Plot library (which is very similar). DFP is now just a wrapper for Plot to ease my maintence burden.

The function exportWeb has been removed because it is to difficult to maintain.

If you want to use this in the browser please use the Plot library instead, e.g.:

const dataframe = ...
const plotConfig = { ... };
const axisMap = { ... };
import { plot } from "plot";
import "@plotex/render-dom";
plot(dataframe.toArray(), plotConfig, axisMap)
    .renderDOM(document.getElementByID("a-chart");

--

As of version 0.4.0 the Nightmare/Electron depenency has been removed along with the renderImage function.

The renderImage function has been moved to the separate library @data-forge-plot/render. This has been removed due to the size that the Electron dependency adds to this package. In the future you you will have to install the separate package to render a plot to an image.

Please note that the sample code below to see how the new library is installed and required to access the renderImage function.

Project Goals

  • To simply and conveniently from a series or dataframe to chart.
  • To create charts and visualizations in Node.js and the browser.
  • To be able to serialize a chart to JSON and then reinstantiate it from the JSON in a web-app.
  • To separate configuration and data definition to make it easy to reuse charts.
  • To configure charts in JSON or fluent API.

Usage

Some instructions for using Data-Forge Plot. These instructions are for JavaScript, but this library also works in TypeScript.

Install

npm install --save data-forge data-forge-plot @plotex/render-image

Setup

    const dataForge = require('data-forge');
    require('data-forge-fs'); // Extends Data-Forge with 'readFile' function.
    require('data-forge-plot'); // Extends Data-Forge with the 'plot' function.
    require('@plotex/render-image'); // Extends Data-Forge Plot with the 'renderImage' function.
    require('@plotex/render-dom'); // Extends Data-Forge Plot with the 'renderDOM' function.

Rendering a chart from a CSV file to an image file

    const dataFrame = await dataForge.readFile("my-data-file.csv").parseCSV();
    await dataFrame.plot().renderImage("my-chart.png");

Rendering a chart to a web page.

    const dataArray = // ... acquire data, e.g. from a REST API ...
    const dataFrame = new DataFrame(dataArray);
    const chartElement = document.getElementById("chart");
    await dataFrame.plot().renderDOM(chartElement);