Class LinePlot Extends Plot
(Defined in: jpgraph_line.php : 24)
 
 LinePlot  Plot 
 AddArea() 
 LinePlot() 
 SetBarCenter() 
 SetColor() 
 SetFastStroke() 
 SetFillColor() 
 SetFillFromYMin() 
 SetFillGradient() 
 SetStepStyle() 
 SetStyle() 
 HideLegend() 
 PreScaleSetup() 
 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: PlotMark DisplayValue
Name Type Description
mark Mark at each data point
value Determine if and hhow each data value should be displayed in the plot

 

See also related classes:
AccLinePlot

 


Class Methods

 

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

ArgumentDefaultDescription
$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");

 

LinePlot ::
LinePlot($datay, $datax)
Public Constructor for LinePlot

ArgumentDefaultDescription
$datay  No description available
$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:

Example:


$lineplot 
= new LinePlot($ydata);

 

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

ArgumentDefaultDescription
$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);

 

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

ArgumentDefaultDescription
$aColor  Color

Description:
Specify color for line. 

Example:

$lp = new LinePlot($ydata);

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

 

LinePlot ::
SetFastStroke($aFlg)
Use Fast version of Stroke()

ArgumentDefaultDescription
$aFlg true 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()

 

LinePlot ::
SetFillColor($aColor, $aFilled)
Specify fill color

ArgumentDefaultDescription
$aColor  Color
$aFilled true Flag. Filled or not

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

Example:

$lp->SetFillColor('green');

 

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

ArgumentDefaultDescription
$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();

 

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

ArgumentDefaultDescription
$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');

 

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

ArgumentDefaultDescription
$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();

 

LinePlot ::
SetStyle($aStyle)
Specify line style.

ArgumentDefaultDescription
$aStyle  Text string to specify line

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

The default line style is 'solid'  
 

See also:

Example:

$lp->SetStyle('dotted');