Issues (459)

src/plot/ErrorLinePlot.php (1 issue)

1
<?php
2
3
/**
4
 * JPGraph v4.0.3
5
 */
6
7
namespace Amenadiel\JpGraph\Plot;
8
9
/**
10
 * @class ErrorLinePlot
11
 * // Description: Combine a line and error plot
12
 * // THIS IS A DEPRECATED PLOT TYPE JUST KEPT FOR
13
 * // BACKWARD COMPATIBILITY
14
 */
15
class ErrorLinePlot extends ErrorPlot
16
{
17
    public $line;
18
19
    /**
20
     * CONSTRUCTOR.
21
     *
22
     * @param mixed $datay
23
     * @param mixed $datax
24
     */
25 1
    public function __construct($datay, $datax = false)
26
    {
27 1
        parent::__construct($datay, $datax);
28
        // Calculate line coordinates as the average of the error limits
29 1
        $n = safe_count($datay);
30 1
        for ($i = 0; $i < $n; $i += 2) {
31 1
            $ly[] = ($datay[$i] + $datay[$i + 1]) / 2;
32
        }
33 1
        $this->line = new LinePlot($ly, $datax);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ly does not seem to be defined for all execution paths leading up to this point.
Loading history...
34 1
    }
35
36
    /**
37
     * PUBLIC METHODS.
38
     *
39
     * @param mixed $graph
40
     */
41 1
    public function Legend($graph)
42
    {
43 1
        if ($this->legend != '') {
44 1
            $graph->legend->Add($this->legend, $this->color);
45
        }
46
47 1
        $this->line->Legend($graph);
48 1
    }
49
50 1
    public function Stroke($img, $xscale, $yscale)
51
    {
52 1
        parent::Stroke($img, $xscale, $yscale);
53 1
        $this->line->Stroke($img, $xscale, $yscale);
54 1
    }
55
} // @class
56