Issues (459)

src/plot/PlotLine.php (3 issues)

Severity
1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Plot;
8
9
use Amenadiel\JpGraph\Util;
10
11
/**
12
 * File:           JPGRAPH_PLOTLINE.PHP
13
 * // Description: PlotLine extension for JpGraph
14
 * // Created:       2009-03-24
15
 * // Ver:           $Id: jpgraph_plotline.php 1931 2010-03-22 15:05:48Z ljp $
16
 * //
17
 * // @class PlotLine
18
 * // Data container class to hold properties for a static
19
 * // line that is drawn directly in the plot area.
20
 * // Useful to add static borders inside a plot to show for example set-values
21
 * //
22
 * // Copyright (c) Asial Corporation. All rights reserved.
23
 */
24
class PlotLine
25
{
26
    public $scaleposition;
27
    public $direction            = -1;
28
    protected $weight            = 1;
29
    protected $color             = 'black';
30
    private $legend              = '';
31
    private $hidelegend          = false;
32
    private $legendcsimtarget    = '';
33
    private $legendcsimalt       = '';
34
    private $legendcsimwintarget = '';
35
    private $iLineStyle          = 'solid';
36
    public $numpoints            = 0; // Needed since the framework expects this property
37
38 2
    public function __construct($aDir = HORIZONTAL, $aPos = 0, $aColor = 'black', $aWeight = 1)
39
    {
40 2
        $this->direction     = $aDir;
41 2
        $this->color         = $aColor;
42 2
        $this->weight        = $aWeight;
43 2
        $this->scaleposition = $aPos;
44 2
    }
45
46
    public function SetLegend($aLegend, $aCSIM = '', $aCSIMAlt = '', $aCSIMWinTarget = '')
47
    {
48
        $this->legend              = $aLegend;
49
        $this->legendcsimtarget    = $aCSIM;
50
        $this->legendcsimwintarget = $aCSIMWinTarget;
51
        $this->legendcsimalt       = $aCSIMAlt;
52
    }
53
54
    public function HideLegend($f = true)
55
    {
56
        $this->hidelegend = $f;
57
    }
58
59
    public function SetPosition($aScalePosition)
60
    {
61
        $this->scaleposition = $aScalePosition;
62
    }
63
64
    public function SetDirection($aDir)
65
    {
66
        $this->direction = $aDir;
67
    }
68
69
    public function SetColor($aColor)
70
    {
71
        $this->color = $aColor;
72
    }
73
74
    public function SetWeight($aWeight)
75
    {
76
        $this->weight = $aWeight;
77
    }
78
79
    public function SetLineStyle($aStyle)
80
    {
81
        $this->iLineStyle = $aStyle;
82
    }
83
84
    public function GetCSIMAreas()
85
    {
86
        return '';
87
    }
88
89
    /**
90
     * PRIVATE METHODS.
91
     *
92
     * @param mixed $graph
93
     */
94
    public function DoLegend($graph)
95
    {
96
        if (!$this->hidelegend) {
97
            $this->Legend($graph);
98
        }
99
    }
100
101
    // Framework function the chance for each plot class to set a legend
102
    public function Legend($aGraph)
103
    {
104
        if ($this->legend != '') {
105
            $dummyPlotMark = new PlotMark();
106
            $lineStyle     = 1;
107
            $aGraph->legend->Add(
108
                $this->legend,
109
                $this->color,
110
                $dummyPlotMark,
111
                $lineStyle,
112
                $this->legendcsimtarget,
113
                $this->legendcsimalt,
114
                $this->legendcsimwintarget
115
            );
116
        }
117
    }
118
119
    public function PreStrokeAdjust($aGraph)
0 ignored issues
show
The parameter $aGraph is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

119
    public function PreStrokeAdjust(/** @scrutinizer ignore-unused */ $aGraph)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
120
    {
121
        // Nothing to do
122
    }
123
124
    // Called by framework to allow the object to draw
125
    // optional information in the margin area
126
    public function StrokeMargin($aImg)
0 ignored issues
show
The parameter $aImg is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

126
    public function StrokeMargin(/** @scrutinizer ignore-unused */ $aImg)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
127
    {
128
        // Nothing to do
129
    }
130
131
    // Framework function to allow the object to adjust the scale
132
    public function PrescaleSetup($aGraph)
0 ignored issues
show
The parameter $aGraph is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

132
    public function PrescaleSetup(/** @scrutinizer ignore-unused */ $aGraph)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
133
    {
134
        // Nothing to do
135
    }
136
137 2
    public function Min()
138
    {
139 2
        return [null, null];
140
    }
141
142 2
    public function Max()
143
    {
144 2
        return [null, null];
145
    }
146
147 2
    public function _Stroke($aImg, $aMinX, $aMinY, $aMaxX, $aMaxY, $aXPos, $aYPos)
148
    {
149 2
        $aImg->SetColor($this->color);
150 2
        $aImg->SetLineWeight($this->weight);
151 2
        $oldStyle = $aImg->SetLineStyle($this->iLineStyle);
152 2
        if ($this->direction == VERTICAL) {
153 1
            $ymin_abs = $aMinY;
154 1
            $ymax_abs = $aMaxY;
155 1
            $xpos_abs = $aXPos;
156 1
            $aImg->StyleLine($xpos_abs, $ymin_abs, $xpos_abs, $ymax_abs);
157 1
        } elseif ($this->direction == HORIZONTAL) {
158 1
            $xmin_abs = $aMinX;
159 1
            $xmax_abs = $aMaxX;
160 1
            $ypos_abs = $aYPos;
161 1
            $aImg->StyleLine($xmin_abs, $ypos_abs, $xmax_abs, $ypos_abs);
162
        } else {
163
            Util\JpGraphError::RaiseL(25125); //(" Illegal direction for static line");
164
        }
165 2
        $aImg->SetLineStyle($oldStyle);
166 2
    }
167
168 2
    public function Stroke($aImg, $aXScale, $aYScale)
169
    {
170 2
        $this->_Stroke(
171 2
            $aImg,
172 2
            $aImg->left_margin,
173 2
            $aYScale->Translate($aYScale->GetMinVal()),
174 2
            $aImg->width - $aImg->right_margin,
175 2
            $aYScale->Translate($aYScale->GetMaxVal()),
176 2
            $aXScale->Translate($this->scaleposition),
177 2
            $aYScale->Translate($this->scaleposition)
178
        );
179 2
    }
180
}
181