rcrist / bar-js

Lightweight, configurable and simple bar chart library in Javascript

Repository from Github https://github.comrcrist/bar-jsRepository from Github https://github.comrcrist/bar-js

bar-js

Lightweight, configurable and simple bar chart library in Javascript

Packagist Codacy grade Chrome Web Store

Description

bar.js is a Canvas based simple Javascript Bar Chart Library to provide a configurable, lightweight and dependency-free experience.

Installation

Download the 'bar.min.js' and include it in your project

<script src="bar.min.js"></script>

Usage

To create the bar chart, you need a block level container like a div or p.

<div id="chart">This will be a bar chart!</div>

Then you can create the BarChart object in your JavaScript file

var barChart = new BarChart(chartID, chartWidth, chartHeight, data);

Parameters

  • 'chartID = containerID (String)' Defines the id of container like "chart"

  • 'chartWidth (Integer)' Defines the width of the chart like 500

  • 'chartHeight (Integer)' Defines the height of the chart like 400

  • 'data (Objects Array)' Defines the data objects. The objects should have 2 key-value pairs: Label and value. Example data:

  var data = [
    {label: 'Jan', value: 123},
    {label: 'Feb', value: 11},
    {label: 'March', value: 55},
    {label: 'April', value: 893},
    {label: 'May', value: 343}
  ];

License

MIT © Rick A. Crist

About

Lightweight, configurable and simple bar chart library in Javascript

License:MIT License


Languages

Language:JavaScript 95.8%Language:HTML 3.4%Language:CSS 0.8%