autochart

1.1.3 • Public • Published

AutoChart

Ever wanted to create a very simple GraphJs chart in seconds chart in seconds to display a dataset you already have? Not for a fancy B2C display but just to see what it's like?

AutoChart is a minimalistic no-dependances package which can accept both objects and array data structure to create a simple graph for you to see.

NodeJS users, you might want to try out quickChart to visualize autochart data inside a browser.

The available chart types are bar, line, radar, doughnut, pie and polarArea.

Installation

npm i autochart

Usage

autochart(data)

const autochart = require('autochart')
 
const data = {
    A: {a: 1, b: 2},
    B: {a: 2, c: 3}
}
 
autochart.bar(data)
autochart.line(data)
autochart.radar(data)
autochart.doughnut(data)
autochart.pie(data)
autochart.polarArea(data)

data can be either an object or an array, in one or two dimensions :

const objectChart = autochart.bar({
    A: {a:1, b:2},
    B: {a:2, b:3}
})
 
/* Returns */
{
    type: "bar",
    data: {
        labels: [
            "A",
            "B"
        ],
        datasets: [
            {
                label: "a",
                backgroundColor: "#F44336",
                data: [
                    1,
                    2
                ]
            },
            {
                label: "b",
                backgroundColor: "#2196F3",
                data: [
                    2,
                    3
                ]
            }
        ]
    }
}
const arrayChart = autoChart.bar([1, 2])
 
/* Returns */
{
    type: "bar",
    data: {
        labels: [
            "0",
        ],
        datasets: [
            {
                label: "0",
                backgroundColor: "#F44336",
                data: [
                    1,
                    2
                ]
            }
        ]
    }
}

Note : hybrid types are possible and missing values are OK

License

MIT © Ivan Sedletzki - Please use and share at will

Special thanks to Dinesh Pandiyan for npm-module-boilerplate

Package Sidebar

Install

npm i autochart

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

8.07 kB

Total Files

5

Last publish

Collaborators

  • noctalivan