add amendments metric
[contractdashboard.git] / lib / jpgraph / jpgraph_plotline.php
blob:a/lib/jpgraph/jpgraph_plotline.php -> blob:b/lib/jpgraph/jpgraph_plotline.php
<?php <?php
/*======================================================================= /*=======================================================================
// File: JPGRAPH_PLOTLINE.PHP // File: JPGRAPH_PLOTLINE.PHP
// Description: PlotLine extension for JpGraph // Description: PlotLine extension for JpGraph
// Created: 2009-03-24 // Created: 2009-03-24
// Ver: $Id: jpgraph_plotline.php 1881 2009-10-01 10:28:12Z ljp $ // Ver: $Id: jpgraph_plotline.php 1881 2009-10-01 10:28:12Z ljp $
// //
// CLASS PlotLine // CLASS PlotLine
// Data container class to hold properties for a static // Data container class to hold properties for a static
// line that is drawn directly in the plot area. // line that is drawn directly in the plot area.
// Useful to add static borders inside a plot to show for example set-values // Useful to add static borders inside a plot to show for example set-values
// //
// Copyright (c) Aditus Consulting. All rights reserved. // Copyright (c) Aditus Consulting. All rights reserved.
//======================================================================== //========================================================================
*/ */
   
class PlotLine { class PlotLine {
public $scaleposition, $direction=-1; public $scaleposition, $direction=-1;
protected $weight=1; protected $weight=1;
protected $color = 'black'; protected $color = 'black';
private $legend='',$hidelegend=false, $legendcsimtarget='', $legendcsimalt='',$legendcsimwintarget=''; private $legend='',$hidelegend=false, $legendcsimtarget='', $legendcsimalt='',$legendcsimwintarget='';
private $iLineStyle='solid'; private $iLineStyle='solid';
public $numpoints=0; // Needed since the framework expects this property public $numpoints=0; // Needed since the framework expects this property
   
function __construct($aDir=HORIZONTAL,$aPos=0,$aColor='black',$aWeight=1) { function __construct($aDir=HORIZONTAL,$aPos=0,$aColor='black',$aWeight=1) {
$this->direction = $aDir; $this->direction = $aDir;
$this->color=$aColor; $this->color=$aColor;
$this->weight=$aWeight; $this->weight=$aWeight;
$this->scaleposition=$aPos; $this->scaleposition=$aPos;
} }
   
function SetLegend($aLegend,$aCSIM='',$aCSIMAlt='',$aCSIMWinTarget='') { function SetLegend($aLegend,$aCSIM='',$aCSIMAlt='',$aCSIMWinTarget='') {
$this->legend = $aLegend; $this->legend = $aLegend;
$this->legendcsimtarget = $aCSIM; $this->legendcsimtarget = $aCSIM;
$this->legendcsimwintarget = $aCSIMWinTarget; $this->legendcsimwintarget = $aCSIMWinTarget;
$this->legendcsimalt = $aCSIMAlt; $this->legendcsimalt = $aCSIMAlt;
} }
   
function HideLegend($f=true) { function HideLegend($f=true) {
$this->hidelegend = $f; $this->hidelegend = $f;
} }
   
function SetPosition($aScalePosition) { function SetPosition($aScalePosition) {
$this->scaleposition=$aScalePosition; $this->scaleposition=$aScalePosition;
} }
   
function SetDirection($aDir) { function SetDirection($aDir) {
$this->direction = $aDir; $this->direction = $aDir;
} }
   
function SetColor($aColor) { function SetColor($aColor) {
$this->color=$aColor; $this->color=$aColor;
} }
   
function SetWeight($aWeight) { function SetWeight($aWeight) {
$this->weight=$aWeight; $this->weight=$aWeight;
} }
   
function SetLineStyle($aStyle) { function SetLineStyle($aStyle) {
$this->iLineStyle = $aStyle; $this->iLineStyle = $aStyle;
} }
   
//--------------- //---------------
// PRIVATE METHODS // PRIVATE METHODS
   
function DoLegend($graph) { function DoLegend($graph) {
if( !$this->hidelegend ) $this->Legend($graph); if( !$this->hidelegend ) $this->Legend($graph);
} }
   
// Framework function the chance for each plot class to set a legend // Framework function the chance for each plot class to set a legend
function Legend($aGraph) { function Legend($aGraph) {
if( $this->legend != '' ) { if( $this->legend != '' ) {
$dummyPlotMark = new PlotMark(); $dummyPlotMark = new PlotMark();
$lineStyle = 1; $lineStyle = 1;
$aGraph->legend->Add($this->legend,$this->color,$dummyPlotMark,$lineStyle, $aGraph->legend->Add($this->legend,$this->color,$dummyPlotMark,$lineStyle,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget); $this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
} }
} }
   
function PreStrokeAdjust($aGraph) { function PreStrokeAdjust($aGraph) {
// Nothing to do // Nothing to do
} }
   
// Called by framework to allow the object to draw // Called by framework to allow the object to draw
// optional information in the margin area // optional information in the margin area
function StrokeMargin($aImg) { function StrokeMargin($aImg) {
// Nothing to do // Nothing to do
} }
   
// Framework function to allow the object to adjust the scale // Framework function to allow the object to adjust the scale
function PrescaleSetup($aGraph) { function PrescaleSetup($aGraph) {
// Nothing to do // Nothing to do
} }
   
function Min() { function Min() {
return array(null,null); return array(null,null);
} }
   
function Max() { function Max() {
return array(null,null); return array(null,null);
} }
   
function _Stroke($aImg,$aMinX,$aMinY,$aMaxX,$aMaxY,$aXPos,$aYPos) { function _Stroke($aImg,$aMinX,$aMinY,$aMaxX,$aMaxY,$aXPos,$aYPos) {
$aImg->SetColor($this->color); $aImg->SetColor($this->color);
$aImg->SetLineWeight($this->weight); $aImg->SetLineWeight($this->weight);
$oldStyle = $aImg->SetLineStyle($this->iLineStyle); $oldStyle = $aImg->SetLineStyle($this->iLineStyle);
if( $this->direction == VERTICAL ) { if( $this->direction == VERTICAL ) {
$ymin_abs = $aMinY; $ymin_abs = $aMinY;
$ymax_abs = $aMaxY; $ymax_abs = $aMaxY;
$xpos_abs = $aXPos; $xpos_abs = $aXPos;
$aImg->StyleLine($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs); $aImg->StyleLine($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs);
} }
elseif( $this->direction == HORIZONTAL ) { elseif( $this->direction == HORIZONTAL ) {
$xmin_abs = $aMinX; $xmin_abs = $aMinX;
$xmax_abs = $aMaxX; $xmax_abs = $aMaxX;
$ypos_abs = $aYPos; $ypos_abs = $aYPos;
$aImg->StyleLine($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs); $aImg->StyleLine($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs);
} }
else { else {
JpGraphError::RaiseL(25125);//(" Illegal direction for static line"); JpGraphError::RaiseL(25125);//(" Illegal direction for static line");
} }
$aImg->SetLineStyle($oldStyle); $aImg->SetLineStyle($oldStyle);
} }
   
function Stroke($aImg,$aXScale,$aYScale) { function Stroke($aImg,$aXScale,$aYScale) {
$this->_Stroke($aImg, $this->_Stroke($aImg,
$aImg->left_margin, $aImg->left_margin,
$aYScale->Translate($aYScale->GetMinVal()), $aYScale->Translate($aYScale->GetMinVal()),
$aImg->width-$aImg->right_margin, $aImg->width-$aImg->right_margin,
$aYScale->Translate($aYScale->GetMaxVal()), $aYScale->Translate($aYScale->GetMaxVal()),
$aXScale->Translate($this->scaleposition), $aXScale->Translate($this->scaleposition),
$aYScale->Translate($this->scaleposition) $aYScale->Translate($this->scaleposition)
); );
} }
} }
   
   
?> ?>