graphing/class.3dbargraph.php
author Dan
Sun, 04 Jan 2009 16:42:52 -0500
changeset 45 53a50ba4d690
parent 43 ce2e9caf2dfa
permissions -rw-r--r--
Added last 60 minutes graph to index.php
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 BarGraph extends CGraph {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     5
    var $bar_width = 32;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     6
    var $bar_height = 8;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     7
    var $bar_padding = 5;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     8
    var $bar_bordercolor = array(39, 78, 120);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     9
    var $bar_bgcolor = array(69, 129, 194);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    10
    var $bar_textfont = 2;
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
    function BarGraph() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    13
      $this->axis_deepness = $this->bar_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    14
      $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
    15
    }
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
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    18
     * Graph::SetBarBorderColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    19
     * Sets border color for bars
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
    function SetBarBorderColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    22
      $this->bar_bordercolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    23
    }
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
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    26
     * Graph::SetBarBackgroundColor()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    27
     * Sets background color for bars
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
    function SetBarBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    30
      $this->bar_bgcolor = array($red, $green, $blue);
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
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    34
     * Graph::SetBarDimensions()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    35
     * Sets with and height of each bar
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    36
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    37
    function SetBarDimensions($width, $height) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    38
      if ($width > 0) $this->bar_width = $width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    39
      if ($height >= 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    40
        $this->bar_height = $height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    41
        $this->axis_deepness = $height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    42
      }
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
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    45
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    46
     * Graph::SetBarPadding()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    47
     * Sets padding (border) around each bar
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    48
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    49
    function SetBarPadding($padding) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    50
      if ($padding > 0) $this->bar_padding = $padding;
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
    function SetBarFont($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    53
      $this->bar_textfont = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    54
      switch ($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    55
        case 'x-large': $this->bar_textfont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    56
        case 'large':   $this->bar_textfont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    57
        case 'medium':  $this->bar_textfont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    58
        case 'small':   $this->bar_textfont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    59
        case 'x-small': $this->bar_textfont++; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    60
        default:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    61
          $this->bar_textfont = $font;
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
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    64
    function DrawGraph($file = "") {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    65
      $this->graph_width = $this->graph_padding['left'] +
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    66
                           (count($this->data) * ($this->bar_width + ($this->bar_padding * 2))) +
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    67
                           $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    68
      $this->axis_deepness = $this->bar_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    69
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    70
      $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
    71
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    72
      $this->axis_frontgridlines = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    73
      $this->axis_xscalevisible = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    74
      $this->axis_positions = array($this->axis_positions[0], 0, 0, 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    75
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    76
      CGraph::DrawGraph();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    77
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    78
      if ($this->axis_minY > 0) $this->axis_minY = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    79
      if ($this->axis_maxY < 0) $this->axis_maxY = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    80
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    81
      $this->__Draw_LeftBottom_Axis();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    82
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    83
      $p = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    84
      foreach ($this->data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    85
        $p++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    86
        $this->__DrawBarText($p, $name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    87
        $this->__DrawBar($p, $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    88
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    89
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    90
      $this->__Draw_TopRight_Axis();
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
      CGraph::DrawGraph2();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    93
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    94
      if (strlen($file)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    95
        $ret = imagepng($this->im, $file);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    96
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    97
        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
    98
        imagepng($this->im);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    99
        $ret = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   100
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   101
      imagedestroy($this->im);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   102
      return $ret;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   103
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   104
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   105
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   106
     * Graph::__DrawBarText()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   107
     * Determines top and left to draw text to a choosen bar
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
    function __DrawBarText($bar, $text) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   110
      $this->__DrawText($text,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   111
                        $this->graph_padding['left'] + (($this->bar_width + ($this->bar_padding * 2)) * ($bar - 0.5)),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   112
                        $this->graph_height - $this->graph_padding['bottom'] + 1,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   113
                        $this->im_axis_scalecolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   114
                        $this->bar_textfont,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   115
                        1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   116
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   117
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   118
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   119
     * Graph::__DrawBar()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   120
     * Draws a choosen bar with it's value
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   121
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   122
    function __DrawBar($bar, $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   123
      $x = $this->graph_padding['left'] +
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   124
           (($this->bar_width + ($this->bar_padding * 2)) * ($bar - 1)) +
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   125
           $this->bar_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   126
      $y = $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
   127
      if ($value >= 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   128
        $this->____DrawBar($x,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   129
                           $this->graph_height - $this->graph_padding['bottom'] - abs(floor($this->axis_minY * $y)) - floor($y * $value),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   130
                           $x + $this->bar_width,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   131
                           $this->graph_height - $this->graph_padding['bottom'] - abs(floor($this->axis_minY * $y)));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   132
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   133
        $this->____DrawBar($x,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   134
                           $this->graph_height - $this->graph_padding['bottom'] - abs(floor($this->axis_minY * $y)),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   135
                           $x + $this->bar_width,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   136
                           $this->graph_height - $this->graph_padding['bottom'] - floor($this->axis_minY * -$y) + floor($y * -$value));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   137
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   138
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   139
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   140
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   141
     * Graph::____DrawBar()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   142
     * Draws the actual rectangles that form a bar
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   143
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   144
    function ____DrawBar($x1, $y1, $x2, $y2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   145
      $this->__AllocateColor("im_bar_bordercolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   146
                             $this->bar_bordercolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   147
                             ( $this->graph_transparencylevel * 1.5));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   148
      $this->__AllocateColor("im_bar_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   149
                             $this->bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   150
                             ( $this->graph_transparencylevel * 1.5));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   151
                             
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   152
      // base square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   153
      $this->__DrawPolygon(array($x1, $y2, $x2, $y2, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   154
                                 $y2 - $this->bar_height, $x1 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   155
                                 $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   156
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   157
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   158
      $this->__DrawPolygon(array($x1, $y2, $x2, $y2, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   159
                                 $y2 - $this->bar_height, $x1 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   160
                                 $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   161
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   162
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   163
      // back square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   164
      $this->__DrawPolygon(array($x1 + $this->bar_height, $y1 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   165
                                 $x2 + $this->bar_height, $y1 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   166
                                 $x2 + $this->bar_height, $y2 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   167
                                 $x1 + $this->bar_height, $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   168
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   169
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   170
      $this->__DrawPolygon(array($x1 + $this->bar_height, $y1 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   171
                                 $x2 + $this->bar_height, $y1 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   172
                                 $x2 + $this->bar_height, $y2 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   173
                                 $x1 + $this->bar_height, $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   174
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   175
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   176
      // left square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   177
      $this->__DrawPolygon(array($x1, $y1, $x1 + $this->bar_height, $y1 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   178
                                 $x1 + $this->bar_height, $y2 - $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   179
                                 $x1, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   180
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   181
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   182
      $this->__DrawPolygon(array($x1, $y1, $x2, $y1, $x2, $y2, $x1, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   183
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   184
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   185
      // front square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   186
      $this->__DrawPolygon(array($x1, $y1, $x2, $y1, $x2, $y2, $x1, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   187
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   188
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   189
      $this->__DrawPolygon(array($x1, $y1, $x2, $y1, $x2, $y2, $x1, $y2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   190
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   191
                           
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   192
      // right square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   193
      $this->__DrawPolygon(array($x2, $y2, $x2, $y1, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   194
                                 $y1 - $this->bar_height, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   195
                                 $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   196
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   197
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   198
      $this->__DrawPolygon(array($x2, $y2, $x2, $y1, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   199
                                 $y1 - $this->bar_height, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   200
                                 $y2 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   201
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   202
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   203
      // top square
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   204
      $this->__DrawPolygon(array($x1, $y1, $x2, $y1, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   205
                                 $y1 - $this->bar_height, $x1 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   206
                                 $y1 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   207
                           $this->im_bar_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   208
                           true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   209
      $this->__DrawPolygon(array($x1, $y1, $x2, $y1, $x2 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   210
                                 $y1 - $this->bar_height, $x1 + $this->bar_height,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   211
                                 $y1 - $this->bar_height),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   212
                           $this->im_bar_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   213
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   214
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   215
    /**
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   216
     * Graph::__Load3dbarValues()
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   217
     * Loads definitions to 3d bar settings
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   218
     **/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   219
    function __Load3dbarValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   220
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   221
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   222
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   223
          case 'background-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   224
            $this->__SetColorToValue("bar_bgcolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   225
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   226
          case 'border-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   227
            $this->__SetColorToValue("bar_bordercolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   228
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   229
          case 'padding':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   230
            $this->bar_padding = $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   231
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   232
          case 'width':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   233
            $this->bar_width = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   234
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   235
          case 'height':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   236
            $this->bar_height = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   237
            $this->axis_deepness = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   238
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   239
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   240
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   241
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   242
  }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   243
?>