CLASS LinePlot EXTENDS Plot (Defined in: jpgraph_line.php : 25)

LinePlot | Plot
AddArea() LinePlot() SetBarCenter() SetColor() SetFastStroke() SetFillColor() SetFillFromYMin() SetFillGradient() SetStepStyle() SetStyle() | HideLegend() SetCenter() SetColor() SetCSIMTargets() SetLegend() SetLineWeight()

Class usage and Overview
This class is used to creat line graph plots. Line graph plots are used to draw standard lineplots where datapoints are connected by lines. Each data point can also be marked by a plotmark.

A line plot can only be added to a Graph() image. Public properties:

Name | Type | Description
--- | --- | ---
PlotMark
mark |  | Mark at each data point
DisplayValue
value |  | Determine if and hhow each data value should be displayed in the plot

See also related classes:
AccLinePlot

Class Methods

function AddArea($aMin,$aMax,$aFilled,$aColor,$aBorder)
Create a colored area under part of the lien graph.

Argument | Default | Description
--- | --- | ---
$aMin | 0 | Start X-value
$aMax | 0 | End X-value
$aFilled | LP_AREA_NOT_FILLED | Fill area or not (true/false)
$aColor | "gray9" | Color of fill
$aBorder | LP_AREA_BORDER | Use a border (true/false)

Description
Create a vertical colored area under the line between two X-values and to the top of the line.

Predefined values for $aFilled are:
LP_AREA_FILLED
LP_AREA_NOT_FILLED

Example

$lineplot->AddArea(2,5,LP_AREA_FILLED,"indianred1");

function LinePlot(&$datay,$datax)
Public Constructor for LinePlot

Argument | Default | Description
--- | --- | ---
&$datay |  | Y-data
$datax | false | X-data

Description
Create a new LinePlot which later can be added to the graph with the Graph::Add() or Graph::AddY2() method.

A plot can be specified with either only Y-values or both Y-and X-values. If both X and Y values are specified they should have the same number of elements.

See also
Graph::Add and Graph::AddY2

Example

$lineplot = new LinePlot($ydata);

function SetBarCenter($aFlag)
Adjust the positioning of line plots when combined with a bar plot

Argument | Default | Description
--- | --- | ---
$aFlag | true | TRUE = Align line points to center of bars

Description
By default the lineplots gets aligned to the left side of the bars when using a text X-scale. By calling this method the line points instead gets aligned to the center of the bars.

This method is only to be used in the case where line and bar plots are combined. Any other use is undefined.

Example

$ydata = array(12,15,22,19,5);
$graph = new Graph(400,200);
$graph->SetScale("textlin");
$line = new LinePlot($ydata);
$line->SetBarCenter();
$bar = new BarPlot($ydata);
$graph->Add($bar);
$graph->Add($line);

function SetColor($aColor)
Set color for the line plot.

Argument | Default | Description
--- | --- | ---
$aColor |  | Color

Description
Specify color for line.

Example

$lp = new LinePlot($ydata);
// Set full blue
$lp->SetColor('#0000FF');

function SetFastStroke($aFlg)
Use Fast version of Stroke()

Argument | Default | Description
--- | --- | ---
$aFlg |  | TRUE=Use fast stroke

Description
Use Fast version of Stroke(). This is useful for line plots which have many thousand points. This method is a lot faster than the usual Stroke() but also have a lot less functionality and puts restriction on the complexity of the line. The lines can have no plotmarks, must be solid and have a line width of 1

Example

$lineplot->SetFastStroke()

function SetFillColor($aColor,$aFilled)
Specify fill color

Argument | Default | Description
--- | --- | ---
$aColor |  | Color
$aFilled | true | Flag. Filled or not

Description
Specify that a lineplot should be filled as well as the fill color.
See also
LinePlot::SetColor

Example

$lp->SetFillColor('green');

function SetFillFromYMin($f)
Fill line not from 0 but from the minimum Y value

Argument | Default | Description
--- | --- | ---
$f | true | TRUE=fill from minimum

Description
Fill line not from 0 (as default) but from the minimum Y value. This is mostly usefull when a plot have the negative value and the X-axis is placed at the minimum Y-alue (at the bottom)

Example

$lineplot->SetFillFromYMin();

function SetFillGradient($aFromColor,$aToColor,$aNumColors,$aFilled)
Specify a gradient fill for the line plot

Argument | Default | Description
--- | --- | ---
$aFromColor |  | Start color
$aToColor |  | End color
$aNumColors | 100 | Number of colors to use in transition
$aFilled | true | TRUE=Enable gradient fill

Description
Specify a gradient fill for the line plot. Currently only vertical gradient fill is supported, i.e. the transiiton from color 1 to color 2 is vertical.

Example

$p1 = new LinePlot($datay);
$p1->SetFillGradient('white','darkgreen');

function SetStepStyle($aFlag)
Use step style for line graph.

Argument | Default | Description
--- | --- | ---
$aFlag | true | Flag. true to use step style.

Description
If the step style is enabled then each point will be connected not with a straight line between the points but with one horizontal and one vertical line. This makes the graph look like a stair where the next data point indicates if the stair is going up or down.

Example

$lp->SetStepStyle();

function SetStyle($aStyle)
Specify line style.

Argument | Default | Description
--- | --- | ---
$aStyle |  | Text string to specify line

Description
Linestyle for lines. Valid linestyles are:
'solid', 'dotted', 'dashed'

The default line style is 'solid'

See also
Image::SetLineStyle

Example

$lp->SetStyle('dotted');