Class BarPlot Extends Plot
(Defined in: jpgraph_bar.php : 30)
 
 BarPlot  Plot 
 RotatePattern() 
 SetAbsWidth() 
 SetAlign() 
 SetFillColor() 
 SetFillGradient() 
 SetNoFill() 
 SetPattern() 
 SetShadow() 
 SetValuePos() 
 SetWidth() 
 SetYBase() 
 SetYMin() 
 __construct() 
 HideLegend() 
 PreScaleSetup() 
 SetCenter() 
 SetColor() 
 SetCSIMTargets() 
 SetLegend() 
 SetLineWeight() 
 

Class usage and Overview
Concrete class which implements the standard vertical bar plot functionality.

To show horizontal plots you can rotate the graph 90 degrees by $graph->Angle(90);

 

See also related classes:
AccBarPlot and GroupBarPlot

 


Class Methods

 

BarPlot ::
RotatePattern($aPat, $aRotate)
// The method will take the specified pattern anre// return a pattern index that corresponds to the original// patterm being rotated 90 degreees. This is needed when plottin// Horizontal bars

ArgumentDefaultDescription
$aPat  No description available
$aRotate true No description available

Description:
No description available.

 

BarPlot ::
SetAbsWidth($aWidth)
Specify width in absolute pixels.

ArgumentDefaultDescription
$aWidth  Width in pixels

Description:
Specify width in absolute pixels. If specified this overrides any calls to SetWidth() 
 
See also:

Example:

$barplot->SetAbsWidth(20);

 

BarPlot ::
SetAlign($aAlign)
Set the alignment between the major tick marks doe the bars.

ArgumentDefaultDescription
$aAlign  String to specify alignment

Description:
Bars can be aligned when using a text scale. Valid arguments for align are 'left', 'center' and 'right'.

Default is to center the bars. 

Example:

$graph->SetScale("textlin");

// ...

$barplot = new BarPlot($ydata,$xdata);
$barplot->SetAlign("center");

// ...

 

BarPlot ::
SetFillColor($aColor)
Specify fill color for bars.

ArgumentDefaultDescription
$aColor  Color specification

Description:
Set fill color for the bars. The color for the frame around the bar is specified with BarPlot::SetColor() method. By specifying an array as argument you can assign individual colors to each of the bars. If there are more bars than colors the colros will wrap around.  
 
See also:

Example:

// All bars will have the same color
$barplot->SetFillColor('#E234A9');

// The bars will haev individual colors
$barplot->SetFillColor(array('red','blue','green'));

 

BarPlot ::
SetFillGradient($aFromColor, $aToColor, $aStyle)
Specify a gradient fill for the bars.

ArgumentDefaultDescription
$aFromColor  No description available
$aToColor null No description available
$aStyle null No description available

Description:
Gradient fill provides a smooth transition from the 'start' color to the 'end' color. The type of gradient fill can be Since gradient fills make use of many colors and bitmapped images which doesn't use truecolor is limited to 256 colors you might find yourself out of colors if using to many different gadient fills in your graph.

You should also be observant that gradient fills makes use of more CPU time than solid fills.  
 

See also:

Example:

$barplot->SetFillgradient('orange','darkred',GRAD_VER);

 

BarPlot ::
SetNoFill()
Dont's paint the interior of the bars with any color.


Description:
Bar plots are filled by default. Calling this method disable the fill of barplots. This is usefull when you have a background in the image that you want to be shown underneth the bars. 
 
See also:

Example:

$barplot->SetNoFill();

 

BarPlot ::
SetPattern($aPattern, $aColor)
Add one of the line patterns to the bar

ArgumentDefaultDescription
$aPattern  Pattern
$aColor 'black' Color of pattern

Description:
Add one of the line patterns as fill effect to the bar. Available patterns are:
  1. 'PATTERN_DIAG1'
  2. 'PATTERN_DIAG2'
  3. 'PATTERN_DIAG3'
  4. 'PATTERN_DIAG4'
  5. 'PATTERN_CROSS1'
  6. 'PATTERN_CROSS2'
  7. 'PATTERN_CROSS3'
  8. 'PATTERN_CROSS4'
  9. 'PATTERN_STRIPE1'
  10. 'PATTERN_STRIPE2'
 

Example:

$barplot->SetPattern('PATTERN_CROSS2');

 

BarPlot ::
SetShadow($aColor, $aHSize, $aVSize, $aShow)
Set a drop shadow for the bar (or rather an "up-right" shadow)

ArgumentDefaultDescription
$aColor "black" No description available
$aHSize 3 No description available
$aVSize 3 No description available
$aShow true No description available

Description:
Set a drop shadow for the bar (or rather an "up-right" shadow) 

Example:

$barplot->SetShadow();

 

BarPlot ::
SetValuePos($aPos)
Specify position for displayed values on bars

ArgumentDefaultDescription
$aPos  Postision

Description:
Specify position for the values on the bar. Teh position can either be  

Example:

// Put the values in the middle of the bars
$barplot->SetValuePos('center');

 

BarPlot ::
SetWidth($aWidth)
Specify width as fractions of the major step size

ArgumentDefaultDescription
$aWidth  No description available

Description:
Specify width as fractions of the major step size when the scale used is a text scale (which is the normal scale to use for bars). If the X-axis scale is a linear scale (i.e. lin, int or date) then the width must be specified in absolute pixels. 
 
See also:

Example:

// Specify fractions for a text scale
$barplot->SetWidth(0.4);

// Specify absolute width 25 pixels
$barplot->SetWidth(25);

 

BarPlot ::
SetYBase($aYStartValue)
Specify the base value for the bars

ArgumentDefaultDescription
$aYStartValue  Strta Y-value for bars.

Description:
Specify the start plot for bars, (minimum Y-value). By default the base uses the value 0 as base. 

Example:

$barplot->SetYBase(100);

 

BarPlot ::
SetYMin($aYStartValue)
DEPRECATED use SetYBase instead

ArgumentDefaultDescription
$aYStartValue  Y-Value for base of bars

Description:
DEPRECATED use SetYBase() instead 

Example:

DEPRECATED use SetYBase() instead

 

BarPlot ::
__construct($datay, $datax)
Create a new bar plot

ArgumentDefaultDescription
$datay  No description available
$datax false X-positions

Description:
Create a new bar plot 

Example:

$bar = new BarPlot($ydata);