0.0.1 • Published 3 years ago

@jorgemoreira/charts v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@jorgemoreira/charts

A library to render bar charts in HTML5 Canvas.

Live Demo

https://jorgemoreira-charts.netlify.app/

Installation

npm install @jorgemoreira/charts

Usage

import { paintChart } from "@jorgemoreira/charts";

const root = document.getElementById("chart-wrapper");
paintChart(root, options);

options properties

NameTypeDescription
typestringRequired. Can be "horizontal-bars" or "vertical-bars".
dataobjectRequired. An object with the data properties.
widthnumberRequired. The canvas width, in pixels.
heightnumberRequired. The canvas height, in pixels.
gridLinesDistancenumberRequired. The distance between the grid lines in the values axis.
titlestringText to display at the top.

data properties

NameTypeDescription
labelsstring[]Required. An array of labels for the category axis.
datasetsobject[]Required. An array of datasets.

dataset properties

NameTypeDescription
labelstringRequired. The label to show in the legend.
valuesnumber[]Required. The dataset values.
colorstringA color value to fill the bars and the legend. See MDN.