Yii 1.1: jqbargraph

This extentions allows you to make bar graphs in few seconds
16 followers

This is my first extention

Requirements

This should work from Yii 1.1

Usage

Installing and using this extension is very simple.

step1: copy the folder into your protected/extensions folder.

step2 include this into import section on config/main

'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.extensions.jqBarGraph.*',
    ),

step3 Then From your View you can call the widget like this

$this->widget('jqBarGraph',array(parameters));

The parameters for simple bargraph are

color1,color2,width,space,title,values;

The bars will be having alternate colors in simple bargraph

  1. color1: color of the first bar;
  2. color2:color of the second bar;
  3. width:width of each bar;
  4. space:space between each bar,
  5. title:title of the graph, will be shown on the top of the graph;
  6. values: Most important, should be an multidimensional array like this;
  7. type:'simple'.

The parameters for multi bargraph are

  1. values: Multi dimensional array;
  2. colors: supports multiple colors so can be given as array.
  3. width: width of bar;
  4. title: title of the graph,will be shown on top of graph;
  5. legend: boolean either true or false;
  6. legends: can be given as array;
  7. type:'multi';

The parameters for stacked bargraph are

  1. values: Multi dimensional array;
  2. colors: supports multiple colors so can be given as array.
  3. width: width of bar;
  4. title: title of the graph,will be shown on top of graph;
  5. legend: boolean either true or false;
  6. legends: can be given as array;
  7. type:'stacked';

So finally the code to call this widget will be like this,

/*this is how you can create a simple graph */
 
$array=array(array(200,'june'),array(129,'july'),array(143,'august'),array(159,'september'));
$this->widget('jqBarGraph',
array('values'=>$array,
'type'=>'simple',
'width'=>200,
'color1'=>'#122A47',
'color2'=>'#1B3E69',
'space'=>5,
'title'=>'simple graph'));
 
/*this is how you can create a multi graph */
 
$array2=array(array(array(5,15,26),2008),array(array(14,6,26),2009),array(array(17,3,26),2010));
$colors=array('#3D0017','#6B0E1D','#AB2522');
$legends=array('legend1','legend2','legend3');
$this->widget('jqBarGraph',
array('values'=>$array2,
'type'=>'multi',
'width'=>500,
'colors'=>$colors,
'legend'=>true,
'legends'=>$legends,
'title'=>'multi graph'));
 
/*this is how you can create a stacked graph */
$array3=array(array(array(5,15,26),2008),array(array(14,6,26),2009),array(array(17,3,29),2010));
$colors2=array('#242424','#437346','#97D95C');
$legends2=array('legend1','legend2','legend3');
$this->widget('jqBarGraph',
array('values'=>$array3,
'type'=>'stacked',
'width'=>500,
'colors'=>$colors2,
'legend'=>true,
'legends'=>$legends2,
'title'=>'stacked graph'));

You can replace the parameters with yours.

See Demo

Then you are done..

Thanks..

Mahesh E.U

Nintriva Wireless

This widget uses the script from jqbargraph. credits:IVAN LAZAREVIC;

Total 6 comments

#11853 report it
FlyngThunderGod at 2013/02/07 03:22pm
conflict

there's a conflict between jqBarGraph and CJuiDatePicker

#11433 report it
MAHESH.E.U at 2013/01/14 03:44am
thanks kapil

Thanks Kapil for that info, I will look into it.

#11432 report it
kapilgopinath at 2013/01/14 03:08am
jQuery conflict

Nice extension but , there is a jquery conflict when graph is displayed along with Yii grid. This is the conflict message 'jQuery(...).live is not a function' which prevents other extensions from displaying. In my case the extension that did'nt work was 'ext.UiGridView.'

#9133 report it
MAHESH.E.U at 2012/07/23 09:22am
thanks..

thanks

#8866 report it
francis ja at 2012/07/05 02:18am
very simple

easy to use...

#8860 report it
sirin k at 2012/07/04 01:39pm
Nice 1

Nice extension mahesh.

Leave a comment

Please to leave your comment.

Create extension
Downloads