graphing/class.linegraph.php
author Dan
Mon, 05 Jan 2009 22:50:59 -0500
changeset 47 633ec114f630
parent 43 ce2e9caf2dfa
permissions -rw-r--r--
Updated news with info on theme support
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     1
<?php
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     2
  require_once dirname(__FILE__) . "/class.graph.php";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     3
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     4
  class LineGraph extends CGraph {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     5
    var $line_color = array(39, 78, 120);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     6
    var $line_bgcolor = array(69, 129, 194);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     7
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     8
    function LineGraph() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     9
      $this->graph_width = $this->graph_padding['left'] + $this->graph_areawidth + $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    10
      $this->graph_height = $this->graph_padding['top'] + $this->graph_areaheight + $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    11
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    12
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    13
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    14
     * Graph::SetLineColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    15
     * Sets line color
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    16
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    17
    function SetLineColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    18
      $this->line_color = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    19
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    20
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    21
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    22
     * Graph::AddLineColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    23
     * Sets line color
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    24
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    25
    function AddLineColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    26
      if (!is_array($this->line_color[0])) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    27
        $this->line_color = array($this->line_color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    28
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    29
      $this->line_color[] = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    30
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    31
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    32
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    33
     * Graph::SetLineBackgroundColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    34
     * Sets background color for line (when 3D)
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    35
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    36
    function SetLineBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    37
      $this->line_bgcolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    38
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    39
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    40
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    41
     * Graph::AddLineBackgroundColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    42
     * Sets line background color
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    43
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    44
    function AddLineBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    45
      if (!is_array($this->line_bgcolor[0])) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    46
        $this->line_bgcolor = array($this->line_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    47
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    48
      $this->line_bgcolor[] = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    49
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    50
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    51
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    52
     * Graph::DrawGraph()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    53
     * Draw all the graph: bg, axis, bars, text.. and output it
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    54
     * Optional file parameter turns output to file, and bool on success
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    55
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    56
    function DrawGraph($file = "") {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    57
      $this->im = imagecreatetruecolor($this->graph_width, $this->graph_height);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    58
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    59
      CGraph::DrawGraph();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    60
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    61
      $this->__Draw_LeftBottom_Axis();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    62
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    63
      $arrki = array_keys($this->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    64
      if (is_array($this->data[$arrki[0]])) { // more than 1 line
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    65
        if (!is_array($this->line_color)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    66
          $this->line_color = array($this->line_color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    67
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    68
        if (!is_array($this->line_bgcolor)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    69
          $this->line_bgcolor = array($this->line_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    70
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    71
        for ($i = 0; $i < count($arrki); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    72
          $this->__AllocateColor("im_line_color",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    73
                                 $this->line_color[$i],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    74
                                 $this->graph_transparencylevel,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    75
                                 $i);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    76
          if ($this->axis_deepness > 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    77
            $this->__AllocateColor("im_line_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    78
                                   $this->line_bgcolor[$i],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    79
                                   $this->graph_transparencylevel,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    80
                                   $i);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    81
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    82
          $arrkj = array_keys($this->data[$arrki[$i]]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    83
          for ($j = 1; $j < count($arrkj); $j++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    84
            $this->__DrawLine(array($arrkj[$j - 1],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    85
                                    $arrkj[$j],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    86
                                    $this->data[$arrki[$i]][$arrkj[$j - 1]],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    87
                                    $this->data[$arrki[$i]][$arrkj[$j]]),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    88
                              $this->im_line_color[$i],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    89
                              $this->im_line_bgcolor[$i]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    90
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    91
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    92
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    93
        $this->__AllocateColor("im_line_color",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    94
                               $this->line_color,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    95
                               $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    96
        $this->__AllocateColor("im_line_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    97
                               $this->line_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    98
                               $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    99
        for ($i = 1; $i < count($arrki); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   100
          $this->__DrawLine(array($i - 1, // x1
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   101
                                  $i,     // x2
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   102
                                  $this->data[$arrki[$i - 1]], // y1
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   103
                                  $this->data[$arrki[$i]]),    // y2
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   104
                            $this->im_line_color,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   105
                            $this->im_line_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   106
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   107
        // exit;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   108
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   109
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   110
      $this->__Draw_TopRight_Axis();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   111
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   112
      CGraph::DrawGraph2();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   113
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   114
      if (strlen($file)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   115
        $ret = imagepng($this->im, $file);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   116
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   117
        header("Content-Type: image/png"); // thanks to Marcin G. :)
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   118
        imagepng($this->im);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   119
        $ret = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   120
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   121
      imagedestroy($this->im);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   122
      return $ret;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   123
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   124
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   125
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   126
     * Graph::__DrawLine()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   127
     * Draws a line between 2 points
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   128
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   129
    function __DrawLine($points, $color, $bgcolor) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   130
      if (!isset($this->line_unitX) || !isset($this->line_unitY)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   131
        $this->line_unitX = ($this->graph_width - $this->graph_padding['left'] - $this->graph_padding['right']) / ($this->axis_maxX - $this->axis_minX);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   132
        $this->line_unitY = $this->graph_areaheight / ($this->axis_maxY - $this->axis_minY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   133
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   134
      $x1 = $this->graph_padding['left'] + floor(($points[0] - $this->axis_minX) * $this->line_unitX) + $this->line_unitX;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   135
      $x2 = $this->graph_padding['left'] + floor(($points[1] - $this->axis_minX) * $this->line_unitX) + $this->line_unitX;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   136
      $y1 = $this->graph_height - $this->graph_padding['bottom'] - floor(($points[2] - $this->axis_minY) * $this->line_unitY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   137
      $y2 = $this->graph_height - $this->graph_padding['bottom'] - floor(($points[3] - $this->axis_minY) * $this->line_unitY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   138
      // echo "drawing line from ($x1, $y1) to ($x2, $y2)<br />";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   139
      if ($this->axis_deepness > 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   140
        $this->__DrawPolygon(array($x1, $y1,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   141
                                   $x1 + $this->axis_deepness, $y1 - $this->axis_deepness,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   142
                                   $x2 + $this->axis_deepness, $y2 - $this->axis_deepness,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   143
                                   $x2, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   144
                             $bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   145
                             true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   146
        $this->__DrawPolygon(array($x1, $y1,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   147
                                   $x1 + $this->axis_deepness, $y1 - $this->axis_deepness,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   148
                                   $x2 + $this->axis_deepness, $y2 - $this->axis_deepness,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   149
                                   $x2, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   150
                             $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   151
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   152
        imageline($this->im, $x1, $y1, $x2, $y2, $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   153
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   154
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   155
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   156
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   157
     * Graph::__LoadLineValues()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   158
     * Loads definitions to line settings
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   159
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   160
    function __LoadLineValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   161
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   162
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   163
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   164
          case 'background-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   165
            $this->__SetColorToValue("line_bgcolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   166
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   167
          case 'color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   168
            $this->__SetColorToValue("line_color", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   169
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   170
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   171
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   172
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   173
  }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   174
?>