Noosphere Possibilities Maximized

npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

videoplot

1.2.7 • Public • Published

travis npm version npm downloads

Install

Prerequisites

Having ffmpeg installed on your computer see fluent-ffmpeg prerequisites

For ubuntu, you should also do

sudo apt-get install libgif-dev

Npm installation

npm install videoplot

Example

First example (1 simple curve) Second example (3 curves)
Example video Example video

Usage

const Videoplot = require('videoplot');
 
var plot = new Videoplot({ w:600, h:600, duration: 30, fps: 8 });
 
// create random data
const y = [];
for(var i = 0; i< 10; i++){
    y.push(Math.random());
}
 
// chartjs dataset format
 
const datasets = [];
datasets.push({
    label : "graph",
    borderColor: "#FFFFFF",
    backgroundColor: "#888888",
    fill: false,
    data : y
});
 
// chartjs dataset format
plot.drawVideoChart({
        type: 'line',
        wScale: 4,
        data: {
            datasets : datasets
        },
        options: {
            elements: {
                point : {
                    pointStyle : 'line'
                }
            },
            scales: {
                xAxes: [{
                    ticks: {
                        display: false
                    }
                }],
                yAxes: [{
                    ticks: {
                        display: false,
                        beginAtZero: true,
                        suggestedMax: 1
                    }
                }],
            }
        }
})
.then(() => {
    console.log("Chart is created");
    // chart is created
    return plot.writeVideoToFile({filename: './examples/example.gif'});
    //return plot.getVideoStream('image/gif');
})
.catch(err => {
    console.error("Error : ", err)
})
.then(() => {
    console.log("Chart is saved into ./examples/example.gif");
})
 

Documentation

Documentation is inside the code as JSDoc.

TO DO

  • better x scale management (labels ...)
  • more chartjs options handling
  • video output handling

Thanks

Thanks to fluent-ffmpeg and chartjs-node

install

npm i videoplot

Downloadsweekly downloads

36

version

1.2.7

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability