LineGraph::Draw PHP Method

Draw() public method

public Draw ( )
    public function Draw()
    {
        $body = $this->Grid() . $this->Guidelines(SVGG_GUIDELINE_BELOW);
        $attr = array('stroke' => $this->stroke_colour, 'fill' => 'none');
        $dash = is_array($this->line_dash) ? $this->line_dash[0] : $this->line_dash;
        $stroke_width = is_array($this->line_stroke_width) ? $this->line_stroke_width[0] : $this->line_stroke_width;
        if (!empty($dash)) {
            $attr['stroke-dasharray'] = $dash;
        }
        $attr['stroke-width'] = $stroke_width <= 0 ? 1 : $stroke_width;
        $bnum = 0;
        $cmd = 'M';
        $y_axis_pos = $this->height - $this->pad_bottom - $this->y0;
        $y_bottom = min($y_axis_pos, $this->height - $this->pad_bottom);
        $path = $fillpath = '';
        $values = $this->GetValues();
        foreach ($values as $key => $value) {
            $point_pos = $this->GridPosition($key, $bnum);
            if (!is_null($value) && !is_null($point_pos)) {
                $x = $point_pos;
                $y = $y_axis_pos - $value * $this->bar_unit_height;
                if ($this->fill_under && $path == '') {
                    $fillpath = "M{$x} {$y_bottom}L";
                }
                $path .= "{$cmd}{$x} {$y} ";
                $fillpath .= "{$x} {$y} ";
                // no need to repeat same L command
                $cmd = $cmd == 'M' ? 'L' : '';
                $this->AddMarker($x, $y, $key, $value);
            }
            ++$bnum;
        }
        $this->line_style = $attr;
        $attr['d'] = $path;
        $graph_line = $this->Element('path', $attr);
        if ($this->fill_under) {
            $attr['fill'] = $this->GetColour(0);
            if ($this->fill_opacity < 1.0) {
                $attr['fill-opacity'] = $this->fill_opacity;
            }
            $fillpath .= "L{$x} {$y_bottom}z";
            $attr['d'] = $fillpath;
            $attr['stroke'] = 'none';
            unset($attr['stroke-dasharray'], $attr['stroke-width']);
            $this->fill_style = $attr;
            $graph_line = $this->Element('path', $attr) . $graph_line;
        }
        $group = array();
        $this->ClipGrid($group);
        $body .= $this->Element('g', $group, NULL, $graph_line);
        $body .= $this->Guidelines(SVGG_GUIDELINE_ABOVE);
        $body .= $this->Axes();
        $body .= $this->CrossHairs();
        $body .= $this->DrawMarkers();
        return $body;
    }