CLASS BarPlot EXTENDS Plot (Defined in: jpgraph_bar.php : 18)

BarPlot | Plot
BarPlot() SetAbsWidth() SetAlign() SetFillColor() SetFillGradient() SetNoFill() SetShadow() SetValuePos() SetWidth() SetYBase() SetYMin() | 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

function BarPlot(&$datay,$datax)
Create a new bar plot

Argument | Default | Description
--- | --- | ---
&$datay |  | Data serie
$datax | false | X-positions

Description
Create a new bar plot

Example

$bar = new BarPlot($ydata);

function SetAbsWidth($aWidth)
Specify width in absolute pixels.

Argument | Default | Description
--- | --- | ---
$aWidth |  | Width in pixels

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

Example

$barplot->SetAbsWidth(20);

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

Argument | Default | Description
--- | --- | ---
$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");
// ...

function SetFillColor($aColor)
Specify fill color for bars.

Argument | Default | Description
--- | --- | ---
$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
Plot::SetColor

Example

// All bars will have the same color
$barplot->SetFillColor('#E234A9');
// The bars will haev individual colors
$barplot->SetFillColor(array('red','blue','green'));

function SetFillGradient($from_color,$to_color,$style)
Specify a gradient fill for the bars.

Argument | Default | Description
--- | --- | ---
$from_color |  | Start color
$to_color |  | End color
$style |  | Type of gradient

Description
Gradient fill provides a smooth transition from the 'start' color to the 'end' color. The type of gradient fill can be

- GRAD_VER, Vertical gradient
- GRAD_HOR, Horizontal gradient
- GRAD_MIDHOR, From the center and out, horizontal
- GRAD_MIDVER, From the center and out, vertical
- GRAD_WIDE_MIDVER, From the center and out, vertical. Wide mid section.
- GRAD_WIDE_MIDHOR, From the center and out, horizontal. Wide mid section.
- GRAD_CENTER, From the center and beaming out
- GRAD_LEFT_REFLECTION, Simulates a reflection on the left side
- GRAD_RIGHT_REFLECTION, Simulates a reflection on the right side

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
Graph::StrokeBackgroundGrad

Example

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

function 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
BarPlot::SetFillColor

Example

$barplot->SetNoFill();

function SetShadow($color,$hsize,$vsize)
Set a drop shadow for the bar (or rather an "up-right" shadow)

Argument | Default | Description
--- | --- | ---
$color | "black" | Shadow color
$hsize | 3 | Horizontal size in pixels
$vsize | 3 | Vertical size in pixels

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

Example

$barplot->SetShadow();

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

Argument | Default | Description
--- | --- | ---
$aPos |  | Postision

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

- 'top', The default value
- 'center'
- 'bottom'

Example

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

function SetWidth($aFractionWidth)
Specify width as fractions of the major step size

Argument | Default | Description
--- | --- | ---
$aFractionWidth |  | Width in fractions

Description
Specify width as fractions of the major step size.
See also
BarPlot::SetAbsWidth

Example

$barplot->SetWidth(0.4);

function SetYBase($aYStartValue)
Specify the base value for the bars

Argument | Default | Description
--- | --- | ---
$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);

function SetYMin($aYStartValue)
DEPRECATED use SetYBase instead

Argument | Default | Description
--- | --- | ---
$aYStartValue |  | Y-Value for base of bars

Description
DEPRECATED use SetYBase() instead

Example

DEPRECATED use SetYBase() instead