data-forge-notebook / plot

The simplest plotting API for JavaScript and TypeScript.
MIT License
19 stars 1 forks source link

Plot

The simplest and most forgiving plotting API for JavaScript and TypeScript.

Use plot to quickly and conveniently render charts for your data. It is an abstraction layer over JavaScript visualization libraries. Currently supporting Apex Charts, but intending to support more in the future.

Click here for the API docs

For various examples see this repo.

Plot can be used from Node.js, from the browser and is specially designed to integrate with Data-Forge Notebook.

Click here to support the developer

Aims

Usage

Some instructions for using plot. These instructions are for JavaScript, but this library also works in TypeScript.

Import plot

Browser

npm install --save plot @plotex/render-dom
const { plot } = require("plot");
require("@plotex/render-dom");

const data = [ /* your data */ ];
const parentEl = /* parent DOM to contain the chart */ ;
const chart = plot(data).renderDOM(parentEl);

Node.js

npm install --save plot @plotex/render-image
const { plot } = require("plot");
require("@plotex/render-image");

const data = [ /* your data */ ];
plot(data).renderImage("my-chart.png");

Data-Forge Notebook

plot is integrated into Data-Forge Notebook.

You can plot an array of JavaScript data like this:

const data = [ /* your data */ ];
display.plot(data);

See more Data-Forge Notebook examples in the exported example visualization notebook.

Pass in configuration options

const data = [ /* your data */ ];
const chartConfig = { chartType: "bar" };
const axisConfig = { x: "Date", y: "Close" };
plot(data, chartConfig, axisConfig)
    .renderDOM(parentEl);

Multiple types of data

Plot an array of numbers

plot([10, 15, 30])
    .renderDOM(parentEl);

Plot an array of JavaScirpt object

plot([ { A: 10, B: 52 }, { A: 15, B: 37 }, A: 30, B: 45 }])
    .renderDOM(parentEl);

Plot by column

plot({ A: [10, 15, 30], B: [52, 37, 45] })
    .renderDOM(parentEl);

Resources

Future

There's more work to be done!

Can you contribute, test or give feedback?

Email the developer on ashley@codecapers.com.au.

Support the developer

Click here to support the developer.

Development stuff

Rebuilding the docs

npm run docs