column bar - Free Download Simple Plain Column Chart Generator In jQuery - bar-chart.js

Free Download Simple Plain Column Chart Generator In jQuery – bar-chart.js

Posted on

This time I will share jQuery Plugin and tutorial about Simple Plain Column Chart Generator In jQuery – bar-chart.js, hope it will help you in programming stack.

column bar - Free Download Simple Plain Column Chart Generator In jQuery - bar-chart.js
File Size: 7.36 KB
Views Total: 1064
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A lightweight yet customizable jQuery bar chart plugin to generate a responsive, vertical, standard or stacked column chart using plain HTML, CSS, JavaScript.

More Features:

  • Custom legend.
  • Custom x- and y-axis lables & text.
  • Custom chart size & title.
  • Renders data from JS array.

How to use it:

1. Create a container in which you’d like to render the column chart.

1 <div id="testDiv"></div>

2. Load the main stylesheet in the head of the document.

1 <link rel="stylesheet" href="main.css" />

3. Load the JavaScript after the latest jQuery library.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/bar-chart.js"></script>

4. Override the default chart data. For a standard column chart, use multiple arrays with 1 value in each array.

01 let data = {
02  
03     // stacked column chart
04     dataValues: [[4, 4, 4], [2, 4, 6], [8, 2, 0], [3, 1, 3]],
05  
06     // legend
07     legend: ["Cheese", "Pepperoni", "Hawaiian"],
08  
09     // legend colors
10     legendColors: ["yellow", "pink", "green"],
11  
12     // x-axis labels
13     barLabels: ["Raphael", "Leonardo", "Michaelangelo", "Donatello"],
14  
15     // x-axis label colors
16     labelColors: ["red", "blue", "orange", "purple"]
17      
18 };

4. Customize the column chart by overriding the default options as displayed below.

01 let options = {
02  
03     // chart width
04     chartWidth: "60%",
05  
06     // chart height
07     chartHeight: "60%",
08  
09     // chart title
10     chartTitle: "Pizza Consumption",
11  
12     // text color of chart title
13     chartTitleColor: "black",
14  
15     // font size
16     chartTitleFontSize: "2rem",
17  
18     // y-axis title
19     yAxisTitle: "Number of Slices Eaten",
20  
21     // x-axis title
22     xAxisTitle: "Ninja Turtles",
23  
24     // "flex-start" (top), "center", or "flex-end" (bottom)
25     barValuePosition: "center",
26  
27     // "1%" (small), "3%" (medium), "5%" (large)
28     barSpacing: "5%"
29      
30 };

5. Override the default jQuery selector of the chart container.

1 let element = "#testDiv";

This awesome jQuery plugin is developed by dexterchan94. For more Advanced Usages, please check the demo page or visit the official website.