graphing/class.graph.php
author Dan
Mon, 05 Jan 2009 22:29:36 -0500
changeset 44 73f74d395f95
parent 43 ce2e9caf2dfa
permissions -rw-r--r--
Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
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
  class CGraph {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     3
    var $data = array();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     4
    //---------------------------------------------
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     5
    var $graph_areaheight = 100;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     6
    var $graph_areawidth = 50;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     7
    var $graph_padding = array('left' => 50, 'top' => 20, 'right'  => 20, 'bottom' => 20);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     8
    var $graph_title = "";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
     9
    var $graph_titlefont = 3;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    10
    var $graph_bgcolor = array(255, 255, 255);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    11
    var $graph_bgtransparent = false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    12
    var $graph_transparencylevel = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    13
    var $graph_borderwidth = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    14
    var $graph_bordercolor = array(218, 218, 239);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    15
    var $graph_titlecolor = array(99, 88, 78);
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
    var $axis_stepX = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    18
    var $axis_stepY = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    19
    var $axis_stepSize = 3;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    20
    var $axis_deepness = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    21
    var $axis_maxX = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    22
    var $axis_minX = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    23
    var $axis_maxY = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    24
    var $axis_minY = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    25
    var $axis_bordercolor = array(99, 88, 78);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    26
    var $axis_bgcolor = array(152, 137, 124);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    27
    var $axis_scalefont = 2;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    28
    var $axis_scalecolor = array(0, 0, 255);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    29
    var $axis_xscalevisible = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    30
    var $axis_yscalevisible = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    31
    var $axis_gridlines = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    32
    var $axis_frontgridlines = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    33
    var $axis_positions = array(true, false, false, true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    34
    var $axis_modeX = 0; // 0=diference between steps 1=number of steps
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    35
    var $axis_modeY = 0; // 0=diference between steps 1=number of steps
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
    var $scale_roundX = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    38
    var $scale_roundY = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    39
    var $scale_funX = "";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    40
    var $scale_funY = "";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    41
    //---------------------------------------------
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    42
    var $legend_visible = false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    43
    var $legend_floating = false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    44
    var $legend_borderwidth = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    45
    var $legend_bgcolor = array(255, 255, 255);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    46
    var $legend_bordercolor = array(0, 0, 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    47
    var $legend_width = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    48
    var $legend_height = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    49
    var $legend_padding = 30;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    50
    var $legend_insidepadding = 3;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    51
    var $legend_font = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    52
    var $legend_position = 3; // 1=bottom left | 2=top left | 3=top right | 4=bottom right
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    53
    var $legend_color = array(array(0, 0, 255));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    54
    var $legend_data = array("Item 1");
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 CGraph() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    57
      //nothing @ the moment.. maybe later will set image at startup
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
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
                                GRAPH
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
    function SetGraphAreaHeight($height) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    64
      if ($height > 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    65
        $this->graph_areaheight = $height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    66
        $this->graph_height = $this->graph_padding['top'] + $height + $this->graph_padding['bottom'];
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
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    69
    function SetGraphAreaWidth($width) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    70
      if ($width > 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    71
        $this->graph_areawidth = $width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    72
        $this->graph_width = $this->graph_padding['left'] + $width + $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    73
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    74
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    75
    function SetGraphPadding($left, $top, $right, $bottom) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    76
      $this->graph_padding = array('left' => (int)$left, 'top' => (int)$top, 'right' => (int)$right, 'bottom' => (int)$bottom);
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
    function SetGraphTitle($title) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    79
      $this->graph_title = $title;
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
    function SetGraphTitleFont($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    82
      $this->graph_titlefont = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    83
      switch ($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    84
        case 'x-large': $this->graph_titlefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    85
        case 'large':   $this->graph_titlefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    86
        case 'medium':  $this->graph_titlefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    87
        case 'small':   $this->graph_titlefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    88
        case 'x-small': $this->graph_titlefont++; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    89
        default:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    90
          $this->graph_titlefont = $font;
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
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    93
    function SetGraphTitleColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    94
      $this->graph_titlecolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    95
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    96
    function SetGraphBorderColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    97
      $this->graph_bordercolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    98
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
    99
    function SetGraphBorderWidth($width = 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   100
      $this->graph_borderwidth = $width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   101
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   102
    function SetGraphBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   103
      $this->graph_bgcolor = array($red, $green, $blue);
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
    function SetGraphBackgroundTransparent($addtransparency = true, $red = 255, $green = 0, $blue = 255) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   106
      $this->graph_bgcolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   107
      $this->graph_bgtransparent = ($addtransparency ? true : false);
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 SetGraphTransparency($percent) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   110
      if ($percent < 0) $percent = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   111
      elseif ($percent > 100) $percent = 127;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   112
      else $percent = $percent * 1.27;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   113
      $this->graph_transparencylevel = $percent;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   114
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   115
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
                                 AXIS
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
    function SetAxisBorderColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   120
      $this->axis_bordercolor = array($red, $green, $blue);
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 SetAxisBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   123
      $this->axis_bgcolor = array($red, $green, $blue);
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
    function SetAxisScaleColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   126
      $this->axis_scalecolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   127
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   128
    function SetAxisStepX($step) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   129
      if ($step > 0) $this->axis_stepX = $step;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   130
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   131
    function SetAxisStepY($step) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   132
      if ($step > 0) $this->axis_stepY = $step;
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
    function SetAxisStepSize($size) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   135
      $this->axis_stepSize = (int) $size;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   136
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   137
    function SetAxisScaleXVisibility($state) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   138
      $this->axis_xscalevisible = ($state ? true : false);
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
    function SetAxisScaleYVisibility($state) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   141
      $this->axis_yscalevisible = ($state ? true : false);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   142
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   143
    function SetAxisModeX($mode) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   144
      switch ($mode) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   145
        case '0':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   146
        case 'value':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   147
          $this->axis_modeX = 0; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   148
        case '1':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   149
        case 'dynamic':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   150
          $this->axis_modeX = 1; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   151
        case '2':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   152
        case 'pixel':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   153
          $this->axis_modeX = 2; break;
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
    function SetAxisModeY($mode) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   157
      switch ($mode) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   158
        case '0':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   159
        case 'value':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   160
          $this->axis_modeY = 0; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   161
        case '1':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   162
        case 'dynamic':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   163
          $this->axis_modeY = 1; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   164
        case '2':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   165
        case 'pixel':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   166
          $this->axis_modeY = 2; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   167
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   168
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   169
    function SetAxisDeepness($deepness) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   170
      $this->axis_deepness = (int) $deepness;
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
    function SetAxisScaleFont($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   173
      $this->axis_scalefont = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   174
      switch ($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   175
        case 'x-large': $this->axis_scalefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   176
        case 'large':   $this->axis_scalefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   177
        case 'medium':  $this->axis_scalefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   178
        case 'small':   $this->axis_scalefont++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   179
        case 'x-small': $this->axis_scalefont++; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   180
        default:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   181
          $this->axis_scalefont = $font;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   182
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   183
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   184
    function SetAxisPositions($positions) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   185
      $positions = explode(",", strtolower($positions));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   186
      $this->axis_positions = array(0, 0, 0, 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   187
      for ($i = 0; $i < count($positions); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   188
        if ($positions[$i][0] == '-') {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   189
          $v = false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   190
          $positions[$i] = substr($positions[$i], 1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   191
        } else $v = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   192
        switch ($positions[$i]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   193
          case 'all':    $this->axis_positions = array($v, $v, $v, $v); break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   194
          case 'left':   $this->axis_positions[0] = $v; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   195
          case 'top':    $this->axis_positions[1] = $v; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   196
          case 'right':  $this->axis_positions[2] = $v; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   197
          case 'bottom': $this->axis_positions[3] = $v; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   198
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   199
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   200
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   201
    function SetAxisGridlines($state) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   202
      $this->axis_gridlines = ($state ? true : false);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   203
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   204
    function SetAxisFrontGridlines($state) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   205
      $this->axis_frontgridlines = ($state ? true : false);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   206
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   207
    /****************************************************************
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   208
                                 SCALE
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   209
    ****************************************************************/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   210
    function SetScaleRoundX($number) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   211
      if ($number < 0) $number = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   212
      $this->scale_roundX = (int) $number;
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
    function SetScaleRoundY($number) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   215
      if ($number < 0) $number = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   216
      $this->scale_roundY = (int) $number;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   217
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   218
    function SetScaleFunctionX($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   219
      $this->scale_funX = $name;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   220
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   221
    function SetScaleFunctionY($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   222
      $this->scale_funY = $name;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   223
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   224
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   225
    /****************************************************************
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   226
                                LEGEND
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   227
    ****************************************************************/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   228
    function SetLegendVisible($visible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   229
      $this->legend_visible = ($visible ? true : false);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   230
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   231
    function SetLegendFloating($floating) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   232
      $this->legend_floating = ($floating ? true : false);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   233
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   234
    function SetLegendBackgroundColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   235
      $this->legend_bgcolor = array($red, $green, $blue);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   236
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   237
    function SetLegendBorderColor($red, $green, $blue) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   238
      $this->legend_bordercolor = array($red, $green, $blue);
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
    function SetLegendBorderWidth($width = 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   241
      $this->legend_borderwidth = $width;
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
    function SetLegendColors($colors) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   244
      $this->__SetColorToValue("legend_color", $colors);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   245
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   246
    function SetLegendPadding($padding = 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   247
      $this->legend_padding = $padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   248
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   249
    function SetLegendInsidePadding($padding = 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   250
      $this->legend_insidepadding = $padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   251
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   252
    function SetLegendPosition($position) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   253
      switch ($position) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   254
        case 1:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   255
        case 'bottom left':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   256
          $this->legend_position = 1; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   257
        case 2:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   258
        case 'top left':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   259
          $this->legend_position = 2; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   260
        case 3:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   261
        case 'top right':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   262
          $this->legend_position = 3; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   263
        case 4:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   264
        case 'bottom right':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   265
          $this->legend_position = 4; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   266
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   267
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   268
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   269
    function SetLegendData($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   270
      if (is_array($data)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   271
        $this->legend_data = $data;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   272
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   273
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   274
    function SetLegentFont($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   275
      $this->legend_font = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   276
      switch ($font) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   277
        case 'x-large': $this->legend_font++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   278
        case 'large':   $this->legend_font++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   279
        case 'medium':  $this->legend_font++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   280
        case 'small':   $this->legend_font++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   281
        case 'x-small': $this->legend_font++; break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   282
        default:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   283
          $this->legend_font = $font;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   284
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   285
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   286
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   287
    /****************************************************************
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   288
                                 DATA
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   289
    ****************************************************************/
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   290
    function SetData($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   291
      if (is_array($data)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   292
        $this->data = $data;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   293
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   294
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   295
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   296
    function LoadGraph($path) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   297
      if (($fp = @fopen($path, "r")) !== false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   298
        $content = "";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   299
        while (!feof($fp)) {              // I do not use filesize() here
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   300
          $content .= fread($fp, 4096);   // because of remote files. If
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   301
        }                                 // there is no problem with them
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   302
        fclose($fp);                      // please let me know
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   303
        $this->__LoadGraphDefinitions($content);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   304
        return true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   305
      } else return false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   306
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   307
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   308
    function DrawGraph() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   309
      if ($this->graph_transparencylevel) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   310
        imagealphablending($this->im, true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   311
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   312
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   313
      if ($this->legend_visible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   314
        $maxlength = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   315
        for ($i = 0; $i < count($this->legend_data); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   316
          if (strlen($this->legend_data[$i]) > $maxlength) $maxlength = strlen($this->legend_data[$i]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   317
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   318
        $this->legend_width = ($this->legend_insidepadding * 4) + ($maxlength * imagefontwidth($this->legend_font));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   319
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   320
        if (!$this->legend_floating) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   321
          $this->graph_padding[($this->legend_position < 3 ? 'left' : 'right')] += $this->legend_padding + $this->legend_width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   322
          $this->graph_areawidth -= ($this->legend_padding + $this->legend_width);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   323
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   324
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   325
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   326
      $this->__PaintBackground();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   327
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   328
      $this->__DrawAxis();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   329
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   330
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   331
    function DrawGraph2() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   332
      if (strlen($this->graph_title)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   333
        $this->__AllocateColor("im_graph_titlecolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   334
                               $this->graph_titlecolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   335
                               $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   336
        $this->__DrawText($this->graph_title,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   337
                          floor($this->graph_width / 2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   338
                          floor(($this->graph_padding['top'] - $this->axis_deepness - imagefontwidth($this->graph_titlefont)) / 2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   339
                          $this->im_graph_titlecolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   340
                          $this->graph_titlefont,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   341
                          1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   342
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   343
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   344
      $this->__DrawLegend();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   345
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   346
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   347
    function __PaintBackground() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   348
      $this->__AllocateColor("im_graph_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   349
                             $this->graph_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   350
                             0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   351
      if ($this->graph_bgtransparent) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   352
        imagecolortransparent($this->im, $this->im_graph_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   353
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   354
      imagefilledrectangle($this->im, 0, 0, $this->graph_width, $this->graph_height, $this->im_graph_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   355
      if ($this->graph_borderwidth) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   356
        $this->__AllocateColor("im_graph_bordercolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   357
                               $this->graph_bordercolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   358
                               $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   359
        for ($i = 0; $i < $this->graph_borderwidth; $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   360
          imagerectangle($this->im,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   361
                         $i,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   362
                         $i,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   363
                         $this->graph_width - 1 - $i,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   364
                         $this->graph_height - 1 - $i,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   365
                         $this->im_graph_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   366
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   367
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   368
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   369
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   370
    function __DrawAxis() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   371
      $this->__AllocateColor("im_axis_bordercolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   372
                             $this->axis_bordercolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   373
                             $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   374
      $this->__AllocateColor("im_axis_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   375
                             $this->axis_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   376
                             $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   377
      $this->__AllocateColor("im_axis_scalecolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   378
                             $this->axis_scalecolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   379
                             $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   380
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   381
      list($this->axis_minX,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   382
           $this->axis_maxX,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   383
           $this->axis_minY,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   384
           $this->axis_maxY) = $this->__GetMinMaxGraphValue();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   385
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   386
      if ($this->axis_gridlines) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   387
        $style = array($this->im_axis_bordercolor, $this->im_graph_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   388
        imagesetstyle($this->im, $style);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   389
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   390
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   391
      if ($this->axis_modeX == 1) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   392
        $this->axis_stepX = ($this->axis_maxX - $this->axis_minX) / $this->axis_stepX;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   393
      } elseif ($this->axis_modeX == 2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   394
        $this->axis_stepX = $this->axis_stepX * ($this->axis_maxX - $this->axis_minX) / $this->graph_areawidth;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   395
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   396
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   397
      if ($this->axis_modeY == 1) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   398
        $this->axis_stepY = ($this->axis_maxY - $this->axis_minY) / $this->axis_stepY;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   399
      } elseif ($this->axis_modeY == 2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   400
        $this->axis_stepY = $this->axis_stepY * ($this->axis_maxY - $this->axis_minY) / $this->graph_areaheight;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   401
        $rest = abs($this->axis_maxY) % $this->axis_stepY;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   402
          // need to center a step on coord 0
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   403
          
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   404
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   405
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   406
      if (!$this->axis_deepness) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   407
        $this->axis_frontgridlines = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   408
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   409
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   410
      if (!$this->axis_xscalevisible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   411
        $this->axis_positions[1] = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   412
        $this->axis_positions[3] = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   413
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   414
      if (!$this->axis_yscalevisible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   415
        $this->axis_positions[0] = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   416
        $this->axis_positions[2] = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   417
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   418
      $this->__CorrectMinMax($this->axis_minX, $this->axis_maxX, $this->axis_stepX);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   419
      $this->__CorrectMinMax($this->axis_minY, $this->axis_maxY, $this->axis_stepY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   420
      if ($this->axis_yscalevisible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   421
        $this->__DrawHorizontalGridlines();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   422
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   423
      $this->__DrawHorizontalGideGridlines();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   424
      if ($this->axis_xscalevisible) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   425
        $this->__DrawVerticalGridlines();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   426
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   427
      $this->__DrawVerticalGideGridlines();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   428
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   429
      // draw lines that separate bars
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   430
      $total_bars = count($this->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   431
      if ( min($this->data) >= 0 && get_class($this) == 'BarGraph' )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   432
      {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   433
        $totalbarwidth = $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
   434
        for ($i = 0; $i < $total_bars; $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   435
          $offset = $this->graph_padding['left'] +
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   436
                    ($totalbarwidth * $i);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   437
          
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   438
          $this->__DrawPolygon(
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   439
                    array(
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   440
                          $offset + $totalbarwidth,                     $this->graph_height - $this->graph_padding['bottom'],                      // top right
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   441
                          $offset,                                      $this->graph_height - $this->graph_padding['bottom'],                      // top left
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   442
                          $offset + $this->bar_height,                  $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height,  // bottom left
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   443
                          $offset + $this->bar_height + $totalbarwidth, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height), // bottom right
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   444
                    $this->im_axis_bgcolor, true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   445
          
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   446
          imageline($this->im,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   447
                    $offset,                         $this->graph_height - $this->graph_padding['bottom'],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   448
                    $offset + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   449
                    $this->im_axis_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   450
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   451
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   452
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   453
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   454
    function __Draw_LeftBottom_Axis() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   455
      $w = $this->graph_width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   456
      $h = $this->graph_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   457
      $p = $this->graph_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   458
      if ($this->axis_positions[3]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   459
        $this->__DrawAxisPart($p['left'], $h - $p['bottom'], $w - $p['right'], $h - $p['bottom'],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   460
                              $this->axis_minX, $this->axis_maxX, $this->axis_stepX,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   461
                              "right", "bottom");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   462
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   463
      if ($this->axis_positions[0]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   464
        $this->__DrawAxisPart($p['left'], $p['top'], $p['left'], $h - $p['bottom'],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   465
                              $this->axis_minY, $this->axis_maxY, $this->axis_stepY,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   466
                              "up", "left");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   467
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   468
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   469
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   470
    function __Draw_TopRight_Axis() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   471
      $w = $this->graph_width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   472
      $h = $this->graph_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   473
      $p = $this->graph_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   474
      if ($this->axis_positions[1]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   475
        $this->__DrawAxisPart($p['left'], $p['top'], $w - $p['right'], $p['top'],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   476
                              $this->axis_minX, $this->axis_maxX, $this->axis_stepX,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   477
                              "right", "top");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   478
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   479
      if ($this->axis_positions[2]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   480
        $this->__DrawAxisPart($w - $p['right'], $p['top'], $w - $p['right'], $h - $p['bottom'],
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   481
                              $this->axis_minY, $this->axis_maxY, $this->axis_stepY,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   482
                              "up", "right");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   483
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   484
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   485
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   486
    function __CorrectMinMax(&$min, &$max, &$step) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   487
      if (($max % $step) != 0) $max += ($step - abs($max % $step));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   488
      if (($min % $step) != 0) $min -= abs($min % $step);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   489
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   490
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   491
    function __DrawHorizontalGridlines() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   492
      $maxy = $this->graph_height - $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   493
      $miny = $this->graph_padding['top'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   494
      $maxx = $this->graph_width - $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   495
      $minx = $this->graph_padding['left'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   496
      $offset = ($maxy - $miny) / ($this->axis_maxY - $this->axis_minY) * $this->axis_stepY;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   497
      $v = $miny + $offset;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   498
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   499
      $deep = $this->axis_deepness;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   500
      if (!$deep) $grid_offset = $this->axis_stepSize;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   501
      else $grid_offset = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   502
      while ($v < $maxy) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   503
        imageline($this->im, $minx + $deep + (!$this->axis_positions[0] ? 0 : $grid_offset),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   504
                             floor($v) - $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   505
                             $maxx + $deep - (!$this->axis_positions[2] ? 0 : $grid_offset),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   506
                             floor($v) - $deep, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   507
        $v += $offset;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   508
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   509
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   510
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   511
    function __DrawHorizontalGideGridlines() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   512
      $maxy = $this->graph_height - $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   513
      $miny = $this->graph_padding['top'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   514
      $maxx = $this->graph_width - $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   515
      $minx = $this->graph_padding['left'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   516
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   517
      $deep = $this->axis_deepness;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   518
      if (!$deep) $grid_offset = $this->axis_stepSize;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   519
      else $grid_offset = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   520
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   521
      if (!$this->axis_positions[1]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   522
        if ($deep) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   523
          imageline($this->im, $minx + $deep + $grid_offset, $miny - $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   524
                    $maxx + $deep + $grid_offset, $miny - $deep, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   525
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   526
        if ($this->axis_frontgridlines) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   527
          imageline($this->im, $minx, $miny, $maxx, $miny, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   528
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   529
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   530
      if (!$this->axis_positions[3]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   531
        if ($deep) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   532
          imageline($this->im, $minx + $deep + $grid_offset, $maxy - $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   533
                    $maxx + $deep + $grid_offset, $maxy - $deep, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   534
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   535
        if ($this->axis_frontgridlines) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   536
          imageline($this->im, $minx, $maxy, $maxx, $maxy, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   537
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   538
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   539
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   540
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   541
    function __DrawVerticalGridlines() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   542
      $maxy = $this->graph_height - $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   543
      $miny = $this->graph_padding['top'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   544
      $maxx = $this->graph_width - $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   545
      $minx = $this->graph_padding['left'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   546
      if ( $this->axis_maxX == 0 )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   547
        $this->axis_maxX = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   548
      $offset = ($maxx - $minx) / ($this->axis_maxX - $this->axis_minX) * $this->axis_stepX;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   549
      $v = $minx + $offset;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   550
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   551
      $deep = $this->axis_deepness;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   552
      if (!$deep) $grid_offset = $this->axis_stepSize;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   553
      else $grid_offset = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   554
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   555
      while ($v < $maxx) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   556
        imageline($this->im, floor($v) + $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   557
                             $miny - $deep + (!$this->axis_positions[1] ? 0 : $grid_offset),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   558
                             floor($v) + $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   559
                             $maxy - $deep - (!$this->axis_positions[3] ? 0 : $grid_offset),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   560
                             IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   561
        $v += $offset;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   562
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   563
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   564
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   565
    function __DrawVerticalGideGridlines() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   566
      $maxy = $this->graph_height - $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   567
      $miny = $this->graph_padding['top'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   568
      $maxx = $this->graph_width - $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   569
      $minx = $this->graph_padding['left'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   570
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   571
      $deep = $this->axis_deepness;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   572
      if (!$deep) $grid_offset = $this->axis_stepSize;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   573
      else $grid_offset = 1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   574
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   575
      if (!$this->axis_positions[0]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   576
        if ($deep) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   577
          imageline($this->im, $minx + $deep + $grid_offset, $miny - $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   578
                    $minx + $deep + $grid_offset, $maxy - $deep, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   579
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   580
        if ($this->axis_frontgridlines) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   581
          imageline($this->im, $minx, $miny, $minx, $maxy, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   582
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   583
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   584
      if (!$this->axis_positions[2]) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   585
        if ($deep) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   586
          imageline($this->im, $maxx + $deep + $grid_offset, $miny - $deep,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   587
                    $maxx + $deep + $grid_offset, $maxy - $deep, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   588
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   589
        if ($this->axis_frontgridlines) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   590
          imageline($this->im, $maxx, $miny, $maxx, $maxy, IMG_COLOR_STYLED);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   591
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   592
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   593
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   594
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   595
    function __DrawAxisPart($x1, $y1, $x2, $y2, $scale_start, $scale_end, $scale_step, $scale_direction, $scaletext_side) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   596
      $deep = $this->axis_deepness;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   597
      if ($deep > 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   598
        $this->__DrawPolygon(array($x1, $y1, $x1 + $deep, $y1 - $deep, $x2 + $deep, $y2 - $deep, $x2, $y2), $this->im_axis_bgcolor, true);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   599
        $this->__DrawPolygon(array($x1, $y1, $x1 + $deep, $y1 - $deep, $x2 + $deep, $y2 - $deep, $x2, $y2), $this->im_axis_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   600
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   601
        imageline($this->im, $x1, $y1, $x2, $y2, $this->im_axis_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   602
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   603
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   604
      // reverse order if needed
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   605
      if ($x1 == $x2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   606
        if ($scale_direction == "up") {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   607
          $scale_direction = "down";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   608
          $v = $scale_start;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   609
          $scale_start = $scale_end;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   610
          $scale_end = $v;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   611
          $scale_step = -$scale_step;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   612
        } else $scale_direction = "down";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   613
        if ($scaletext_side != "left") $scaletext_side = "right";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   614
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   615
        if ($scale_direction == "left") {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   616
          $scale_direction = "right";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   617
          $v = $scale_start;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   618
          $scale_start = $scale_end;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   619
          $scale_end = $v;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   620
          $scale_step = -$scale_step;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   621
        } else $scale_direction = "right";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   622
        if ($scaletext_side != "top") $scaletext_side = "bottom";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   623
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   624
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   625
      $v = $scale_start;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   626
      $total = $scale_end - $v;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   627
      if ($x1 == $x2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   628
        $totalarea = $this->graph_areaheight;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   629
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   630
        $totalarea = $this->graph_areawidth;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   631
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   632
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   633
      $akeys = array_keys($this->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   634
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   635
      while (($v <= $scale_end && $scale_step > 0) || ($v >= $scale_end && $scale_step < 0)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   636
        if ($x1 == $x2) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   637
          $offset = ceil($y1 + (($v - $scale_start) * $totalarea / $total));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   638
          if (strlen($this->scale_funY)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   639
            $fun = str_replace("%d", $v, $this->scale_funY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   640
            eval("\$scale_value = " . $fun . ";");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   641
          } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   642
            $scale_value = $this->__RoundNumber($v, $this->scale_roundY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   643
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   644
          // vertical axis scale text
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   645
          $this->__DrawText($scale_value, $x1 + ($scaletext_side == "left" ? -6 : 6 + $deep),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   646
                            $offset, $this->im_axis_scalecolor, $this->axis_scalefont,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   647
                            ($scaletext_side == "left" ? 2 : 0), 1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   648
          if ($v != $scale_start && $v != $scale_end) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   649
            // vertical axis scale line
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   650
            imageline($this->im, $x1 + ($scaletext_side == "left" ? 1 : -1), $offset,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   651
                      $x1 + ($scaletext_side == "left" ? $this->axis_stepSize : -$this->axis_stepSize),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   652
                      $offset - $this->axis_stepSize + ($scaletext_side == "left" ? 1 : -1), $this->im_axis_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   653
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   654
        } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   655
          $offset = floor($x1 + (($v - $scale_start) * $totalarea / $total));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   656
          if (function_exists($this->scale_funX)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   657
            $fun = $this->scale_funX;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   658
            $scale_value = $fun($v, $this);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   659
          } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   660
            $use_int = true;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   661
            if ( isset($akeys[$v]) )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   662
              if ( is_string($akeys[$v]) && !ctype_digit($akeys[$v]) )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   663
                $use_int = false;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   664
            $scale_value = $use_int ? $this->__RoundNumber($v, $this->scale_roundX) : $akeys[$v];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   665
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   666
          // horizontal axis scale text
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   667
          $this->__DrawText($scale_value, $offset, $y1 + ($scaletext_side == "top" ? -6 - $deep : 6),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   668
                            $this->im_axis_scalecolor, $this->axis_scalefont, 1,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   669
                            ($scaletext_side == "top" ? 2 : 0));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   670
          if ($v != $scale_start && $v != $scale_end) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   671
            // horizontal axis scale line
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   672
            imageline($this->im, $offset, $y1 + ($scaletext_side == "top" ? 1 : -1),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   673
                      $offset,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   674
                      $y1 + ($scaletext_side == "top" ? $this->axis_stepSize : -$this->axis_stepSize),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   675
                      $this->im_axis_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   676
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   677
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   678
        $v += $scale_step;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   679
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   680
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   681
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   682
    function __DrawText($text, $x, $y, $color, $size = 1, $align = 0, $valign = 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   683
      /* Align: 0=left | 1=center | 2=right */
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   684
      if ($align == 1) $x -= floor(strlen($text) * imagefontwidth($size) / 2);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   685
      elseif ($align == 2) $x -= (strlen($text) * imagefontwidth($size));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   686
      if ($valign == 1) $y -= floor(imagefontheight($size) / 2);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   687
      elseif ($valign == 2) $y -= imagefontheight($size);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   688
      imagestring($this->im, $size, $x, $y, $text, $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   689
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   690
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   691
    function __GetMinMaxGraphValue() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   692
      $arrki = array_keys($this->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   693
      if (is_array($this->data[$arrki[0]])) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   694
        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
   695
          $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
   696
          if ($i == 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   697
            $maxX = $minX = (int) $arrkj[0];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   698
            $maxY = $minY = (int) $this->data[$arrki[0]][$arrkj[0]];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   699
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   700
          for ($j = 0; $j < count($arrkj); $j++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   701
            if ($arrkj[$j] > $maxX) $maxX = $arrkj[$j];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   702
            elseif ($arrkj[$j] < $minX) $minX = $arrkj[$j];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   703
            if ($this->data[$arrki[$i]][$arrkj[$j]] > $maxY) $maxY = $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
   704
            elseif ($this->data[$arrki[$i]][$arrkj[$j]] < $minY) $minY = $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
   705
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   706
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   707
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   708
        $maxY = $minY = (int) $this->data[$arrki[0]];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   709
        foreach ($this->data as $x => $y) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   710
          if ($y > $maxY) $maxY = $y;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   711
          elseif ($y < $minY) $minY = $y;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   712
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   713
        $minX = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   714
        $maxX = count($this->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   715
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   716
      if ( $maxY == 0 )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   717
      {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   718
        $maxY = 10;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   719
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   720
      return array($minX, $maxX, $minY, $maxY);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   721
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   722
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   723
    function __DrawPolygon($points, $color, $filled = false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   724
      if ($filled) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   725
        imagefilledpolygon($this->im, $points, 4, $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   726
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   727
        imagepolygon($this->im, $points, 4, $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   728
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   729
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   730
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   731
    function __LoadGraphDefinitions($text) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   732
      $text = preg_split("/\r?\n/", $text);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   733
      $data = array();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   734
      $section = '';
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   735
      for ($i = 0; $i < count($text); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   736
        if (preg_match("/^\s*#/", $text[$i])) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   737
          //ignore.. it's just a comment
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   738
        } elseif (preg_match("/^\s*\}\s*/", $text[$i])) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   739
          $section = '';
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   740
        } elseif (preg_match("/^\s*(\w+)\s*\{\s*$/", $text[$i], $r)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   741
          $section = $r[1];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   742
          $index = -1;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   743
        } elseif (preg_match("/^\s*\-\s*$/", $text[$i]) && strlen($section)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   744
          $index++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   745
        } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   746
          $p = strpos($text[$i], "=");
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   747
          if ($p !== false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   748
            $k = trim(substr($text[$i], 0, $p));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   749
            $v = trim(substr($text[$i], $p + 1));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   750
            if ($index >= 0) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   751
              $data[$section][$index][$k] = $v;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   752
            } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   753
              if (preg_match("/^\s*\[(.*)\]\s*$/", $v, $r)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   754
                // array
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   755
                $data[$section][$k] = explode(";", $r[1]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   756
              } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   757
                $data[$section][$k] = $v;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   758
              }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   759
            }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   760
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   761
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   762
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   763
      foreach ($data as $key => $settings) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   764
        $func = "__Load" . ucfirst($key) . "Values";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   765
        if (method_exists($this, $func)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   766
          $this->$func($settings);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   767
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   768
      }
44
73f74d395f95 Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
Dan
parents: 43
diff changeset
   769
      if (isset($data['data']) && is_array($data['data'])) {
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   770
        $this->data = $data['data'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   771
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   772
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   773
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   774
    function __LoadGraphValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   775
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   776
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   777
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   778
          case 'background-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   779
            $this->__SetColorToValue("graph_bgcolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   780
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   781
          case 'border-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   782
            $this->__SetColorToValue("graph_bordercolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   783
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   784
          case 'title-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   785
            $this->__SetColorToValue("graph_titlecolor", $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   786
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   787
          case 'background-transparent':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   788
            $this->graph_bgtransparent = ($value == 1 || $value == 'yes' ? 1 : 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   789
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   790
          case 'transparency':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   791
            $this->SetGraphTransparency(str_replace('%', '', $value));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   792
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   793
          case 'title':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   794
            $this->graph_title = $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   795
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   796
          case 'title-font':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   797
            $this->SetGraphTitleFont($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   798
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   799
          case 'border-width':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   800
            $this->graph_borderwidth = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   801
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   802
          case 'area-height':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   803
            $this->graph_areaheight = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   804
            $this->graph_height = $this->graph_padding['top'] + (int)$value + $this->graph_padding['bottom'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   805
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   806
          case 'area-width':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   807
            $this->graph_areawidth = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   808
            $this->graph_width = $this->graph_padding['left'] + (int)$value + $this->graph_padding['right'];
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   809
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   810
          default:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   811
            if (substr($name, 0, 8) == 'padding-' && strlen($name) > 8) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   812
              $this->graph_padding[substr($name, 8)] = $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   813
            }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   814
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   815
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   816
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   817
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   818
    function __LoadAxisValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   819
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   820
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   821
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   822
          case 'x-step':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   823
            $this->SetAxisStepX($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   824
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   825
          case 'y-step':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   826
            $this->SetAxisStepY($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   827
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   828
          case 'step-size':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   829
            $this->axis_stepSize = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   830
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   831
          case 'x-step-mode':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   832
            $this->SetAxisModeX($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   833
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   834
          case 'y-step-mode':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   835
            $this->SetAxisModeY($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   836
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   837
          case 'background-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   838
          case 'border-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   839
          case 'scale-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   840
            $this->__SetColorToValue("axis_" . str_replace(array("ackground", "-"),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   841
                                                           array("g", ""),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   842
                                                           $name),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   843
                                     $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   844
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   845
          case 'scale-font':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   846
            $this->SetAxisScaleFont($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   847
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   848
          case 'show-xscale':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   849
            $this->axis_xscalevisible = ($value == 1 || $value == 'yes' ? 1 : 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   850
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   851
          case 'show-yscale':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   852
            $this->axis_yscalevisible = ($value == 1 || $value == 'yes' ? 1 : 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   853
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   854
          case 'gridlines':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   855
            $this->axis_gridlines = ($value == 1 || $value == 'yes' ? 1 : 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   856
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   857
          case 'position':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   858
            $this->SetAxisPositions($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   859
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   860
          case 'deepness':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   861
            $this->axis_deepness = (int) $value;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   862
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   863
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   864
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   865
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   866
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   867
    function __LoadScaleValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   868
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   869
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   870
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   871
          case 'x-round':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   872
            $this->SetScaleRoundX($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   873
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   874
          case 'y-round':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   875
            $this->SetScaleRoundY($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   876
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   877
          case 'x-fun':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   878
            $this->SetScaleFunctionX($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   879
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   880
          case 'y-fun':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   881
            $this->SetScaleFunctionY($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   882
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   883
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   884
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   885
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   886
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   887
    function __LoadLegendValues($data) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   888
      foreach ($data as $name => $value) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   889
        $name = strtolower($name);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   890
        switch ($name) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   891
          case 'background-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   892
          case 'border-color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   893
          case 'color':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   894
            $this->__SetColorToValue("legend_" . str_replace(array("ackground", "-"),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   895
                                                             array("g", ""),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   896
                                                             $name),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   897
                                     $value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   898
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   899
          case 'visible':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   900
            $this->SetLegendVisible($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   901
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   902
          case 'floating':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   903
            $this->SetLegendFloating($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   904
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   905
          case 'position':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   906
            $this->SetLegendPosition($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   907
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   908
          case 'borderwidth':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   909
            $this->SetLegendBorderWidth($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   910
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   911
          case 'padding':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   912
            $this->SetLegendPadding($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   913
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   914
          case 'inside-padding':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   915
            $this->SetLegendInsidePadding($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   916
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   917
          case 'data':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   918
            $this->SetLegendData($value);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   919
            break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   920
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   921
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   922
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   923
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   924
    function __SetColorToValue($varname, $color, $index = false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   925
      if (is_array($color)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   926
        for ($i = 0; $i < count($color); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   927
          $this->__SetColorToValue($varname, $color[$i], $i);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   928
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   929
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   930
        if ($color[0] == "#") { // if it's hex (html format), change to rgb array
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   931
          if (strlen($color) == 4) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   932
            // if only 3 hex values (I assume it's a shade of grey: #ddd)
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   933
            $color .= substr($color, -3);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   934
          }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   935
          $color = array(hexdec($color[1].$color[2]),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   936
                         hexdec($color[3].$color[4]),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   937
                         hexdec($color[5].$color[6]));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   938
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   939
        if ($index !== false) $this->{$varname}[$index] = $color;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   940
        else $this->$varname = $color;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   941
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   942
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   943
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   944
    function __AllocateColor($varname, $color, $alpha, $index = false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   945
      if ($index !== false) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   946
        $this->{$varname}[$index] = imagecolorallocatealpha($this->im, $color[0], $color[1], $color[2], $alpha);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   947
      } else {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   948
        $this->$varname = imagecolorallocatealpha($this->im, $color[0], $color[1], $color[2], $alpha);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   949
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   950
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   951
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   952
    function __DrawLegend() {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   953
      if (!$this->legend_visible) return;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   954
      
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   955
      $this->legend_height = $this->legend_insidepadding + (count($this->legend_data) * (imagefontheight($this->legend_font) + $this->legend_insidepadding));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   956
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   957
      switch ($this->legend_position) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   958
        case 1:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   959
          $x = $this->legend_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   960
          $y = $this->graph_height - $this->legend_padding - $this->legend_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   961
          break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   962
        case 2:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   963
          $x = $y = $this->legend_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   964
          break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   965
        case 3:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   966
          $x = $this->graph_width - $this->legend_padding - $this->legend_width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   967
          $y = $this->legend_padding;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   968
          break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   969
        case 4:
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   970
          $x = $this->graph_width - $this->legend_padding - $this->legend_width;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   971
          $y = $this->graph_height - $this->legend_padding - $this->legend_height;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   972
          break;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   973
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   974
      if ($this->legend_floating) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   975
        $x = $x + ($this->legend_position < 3 ? $this->graph_padding['left'] : -$this->graph_padding['right']);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   976
        $y = $y + ($this->legend_position == 2 || $this->legend_position == 3 ? $this->graph_padding['top'] : -$this->graph_padding['bottom']);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   977
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   978
      $this->__AllocateColor("im_legend_bordercolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   979
                             $this->legend_bordercolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   980
                             $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   981
      $this->__AllocateColor("im_legend_bgcolor",
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   982
                             $this->legend_bgcolor,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   983
                             $this->graph_transparencylevel);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   984
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   985
      imagefilledrectangle($this->im, $x + 1, $y + 1, $x + $this->legend_width - 1, $y + $this->legend_height - 1, $this->im_legend_bgcolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   986
      imagerectangle($this->im, $x, $y, $x + $this->legend_width, $y + $this->legend_height, $this->im_legend_bordercolor);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   987
      for ($i = 0; $i < count($this->legend_data); $i++) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   988
        $this->__AllocateColor("im_legend_color", $this->legend_color[$i], $this->graph_transparencylevel, $i);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   989
        $this->__DrawLegendItem($x, $y, $i, $this->legend_data[$i], $this->im_legend_color[$i]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   990
      }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   991
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   992
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   993
    function __DrawLegendItem($legendx, $legendy, $position, $text, $color) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   994
      $x = $legendx + $this->legend_insidepadding * 3;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   995
      $y = $legendy + $this->legend_insidepadding + (($this->legend_insidepadding + imagefontheight($this->legend_font)) * $position);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   996
      imagefilledrectangle($this->im, $legendx + $this->legend_insidepadding,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   997
                                      $y + ((imagefontheight($this->legend_font) - $this->legend_insidepadding) / 2),
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   998
                                      $legendx + $this->legend_insidepadding * 2,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
   999
                                      $y + ((imagefontheight($this->legend_font) - $this->legend_insidepadding) / 2) + $this->legend_insidepadding,
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1000
                                      $color);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1001
      $this->__DrawText($text, $x, $y, $color, $this->legend_font, 0, 0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1002
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1003
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1004
    function __RoundNumber($n, $round = 1) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1005
      if (is_numeric($n)) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1006
        $weights = " KMG";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1007
        $p = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1008
        while (abs($n) >= 1000) {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1009
          $n = $n / 1000;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1010
          $p++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1011
        }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1012
        return number_format($n, $round) . trim($weights[$p]);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1013
      } else return $n;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1014
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1015
  }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents:
diff changeset
  1016
?>