jqBarGraph – jQuery graph plugin

jqBarGraph is jQuery plugin that gives you freedom to easily display your data as graphs. There are three types of graphs: simple, multi and stacked. All you have to do is to pass your data to this plugin. This plugin is compatible and fully tested with Safari 2+, Internet Explorer 6+, Firefox 2+, Google Chrome 3+, Opera 9+.

jQuery Bar Graph

Of course, there are a lot of settings to tune appearance of your graph, as are animation, color scheme, dimensions etc. Also, you can additionally change look and feel of graph via CSS.

You will need jQuery in order to make jqBarGraph working. First, you need to download jQuery and jqBarGraph plugin and include them on your page. Similar to this:

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jqBarGraph.js" type="text/javascript"></script>

Now, we need array of data from which we want to create graph. There is two type of data array for jqBarGraph. First is for simple bar graph type, and second is for multi and stacked bar type.

For simple bar graph type data for one bar should look like this: [value, label, color]. Label and color are optional. This is example for simple bar graph type:

arrayOfData = new Array(

For multi and stacked type of graph you should send data in next format: [[value1, value2, value3, …, valueN], label]. It should look similar to this:

arrayOfData = new Array(

After you set your data array you just need to say in which div you want graph to be created. All you have to do is:

$('#divForGraph').jqBarGraph({ data: arrayOfData }); 

The code above is enough to display your data as bar graph. But if you want to made your graph prettier you can achieve that with next set of parameters:

data: arrayOfData, // array of data for your graph
title: false, // title of your graph, accept HTML
barSpace: 10, // this is default space between bars in pixels
width: 400, // default width of your graph
height: 200, //default height of your graph
color: '#000000', // if you don't send colors for your data this will be default bars color
colors: false, // array of colors that will be used for your bars and legends
lbl: '', // if there is no label in your array
sort: false, // sort your data before displaying graph, you can sort as 'asc' or 'desc'
position: 'bottom', // position of your bars, can be 'bottom' or 'top'. 'top' doesn't work for multi type
prefix: '', // text that will be shown before every label
postfix: '', // text that will be shown after every label
animate: true, // if you don't need animated appearance change to false
speed: 2, // speed of animation in seconds
legendWidth: 100, // width of your legend box
legend: false, // if you want legend change to true
legends: false, // array for legend. for simple graph type legend will be extracted from labels if you don't set this
type: false, // for multi array data default graph type is stacked, you can change to 'multi' for multi bar type
showValues: true, // you can use this for multi and stacked type and it will show values of every bar part 
showValuesColor: '#fff' // color of font for values

This graph will work without any additional CSS, but it can easily be styled via CSS. I was paying attention that you will have enough selectors to achieve anything you want with CSS. If you create something cool it will be nice if you share that with all of us.



* Compatibility with jQuery 1.4.2+

  • Image gallery with fancy transitions effects (1021)
    I was looking all over the Internet for some jQuery gallery plugin with some interesting transition effects. I found a lot of great plugins but they all have pretty same transition […]
  • Visualize Twitter connections with Twings (3)
    I always find it interesting to see who from people that I’m following on Twitter follows me back and also to see how those people are related with each others. I was looking the best way […]
  • News Ticker in 4 lines of jQuery (91)
    There are a lot of different jQuery News Ticker plugins with lot of options that you can use. Do you want to learn how to create one on your own in only 4 lines of jQuery code […]
  • Gradienter: Add gradient to elements (22)
    Last night I started to work on Wordpress theme for blog and I got an idea that every post should have their own background color and that maybe those colors can be in gradient. Since that […]
  • mooBarGraph: AJAX graph for MooTools (17)
    mooBarGraph is AJAX graph plugin for MooTools which support two types of graphs, simple bar and stacked bar graph. This plugin made graph from your JSON data and is compatible with all […]

157 comments on "jqBarGraph – jQuery graph plugin"

@Dario Villanueva
Height will define maximum value, maybe you can use that.

I didn’t have a chance to test it on iPhone, I’m glad that works fine.

Thanks for comments, I really appreciate it.

Lazarevic Ivan on June 13, 2010 at 8:52 am

Now this is a JS charting tool that can take on the Flash equivalents. Well done!! This is the only solution we have found that contains animation similar to FusionCharts. Do you have plans to develop other charts eg line chart?

We have looked at so many JS solutions of charts that work on the iPhone/Safari browser but none of them work as good as this. Graphael come very close (and that very impressive) but it’s not animated and let’s face it, that’s what users want to see.


Roly on June 9, 2010 at 8:37 pm

Fantastic plugin, It’s really clean and beautifully animated. It’d be great however if you could add an option to define the scale, i.e. the maximum value. I’m making a page with a lot of independent graphs that scale automatically according to their own dataset, but i’d want them to all scale the same so they could be comparable. Other than that, fantastic plugin A++++


Dario Villanueva on June 4, 2010 at 3:30 am

Great plug-in, thanks!

Question is there a way to make it a horizontal graph?

Thanks again!

erica on May 11, 2010 at 1:12 pm

You can add grids as background image. I know that it’s not a perfect solution : )

Lazarevic Ivan on April 13, 2010 at 2:08 pm

Hi, Nice work there.
But one thing , what about X and Y grid view?

M A Hossain Tonu on April 12, 2010 at 4:27 am

Philip, there is no option for that, but you can change source code if you know how to achieve that. If you need help feel free to contact me.

Lazarevic Ivan on April 11, 2010 at 4:13 am

Is it possible to reverse the order of the legend so that the legend match the sequence of the stacked graph?

Philip on April 8, 2010 at 12:55 pm

Stvarno dobar plugin. Svaka cast..
Naisao sam na jedan problem: Kada jednom iskoristim hide() na elementu kome grafik pripada,grafik se vise ne prikazuje, naravno isto je i iz css-a display:none


Dakle, kada sakrijem prvi_blok a kasnije zelim da ga prikazem, grafik se jednostavno izgubi.
Kod prikaza sam koristio jednostavno show() ili toggle()

U cemu je problem? Mozda negde gresim

Predic on March 15, 2010 at 5:11 am

Pravin, after Ajax response on success just create graph again with data from response.

Lazarevic Ivan on March 4, 2010 at 1:13 pm

Thanks for developing such a good plugins.
I need help regarding the arrayOfData. In our example we have to generate arrayOfData using jsp file. So how can I get the arrayOfData as a Ajax response.

Please help me out.

Pravin on March 3, 2010 at 9:22 am

Odličan plugin. Jednostavan za koristenje, super izgleda…

Ozren on February 17, 2010 at 6:12 am

That’s a good question tplaner. For now, you should clear graph container div before drawing new graph. Something similar is done on jqBarGraph’s page examples part. This is code snippet from there.

$(‘#exampleMulti’).jqbargraph({ data: arrayOfDataMultiForSort });


Thanks for feedback. I’ll fix this in next release.

Lazarevic Ivan on December 18, 2009 at 2:01 pm

Excellent plug-in well designed and coded for displaying basic bar charts. I really like how browser compatible these bar charts are since they do not rely on the canvas element.

One question though, I was wondering how you would go about updating the charts in semi-real-time? For example if you had animation set to false, how would you then simply add to the data set on the screen?

I attempted to simply modify the data and pass it back to the jqBarGraph function, however it doesn’t seem to be working correctly (I end up with overlapping text).

tplaner on December 18, 2009 at 9:31 am

Leave a Reply

Your email address will not be published. Required fields are marked *