htdocs/graph.php
author Dan
Sun, 04 Jan 2009 16:42:52 -0500
changeset 45 53a50ba4d690
parent 43 ce2e9caf2dfa
child 44 73f74d395f95
permissions -rw-r--r--
Added last 60 minutes graph to index.php
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     1
<?php
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     2
require('../stats-fe.php');
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     3
require('../graphs.php');
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     4
require('../timezone.php');
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     5
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     6
$channel_list = stats_channel_list();
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     7
$first_channel = $channel_list[0];
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     8
$channel = ( isset($_REQUEST['channel']) && in_array($_REQUEST['channel'], $channel_list) ) ? $_REQUEST['channel'] : $first_channel;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
     9
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    10
function makeGraph($type = 'bar')
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    11
{
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    12
  $class = ( $type == 'line' ) ? 'LineGraph' : 'BarGraph';
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    13
  $g = new $class(); // _Compat();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    14
  
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    15
  $g->SetGraphAreaHeight(200);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    16
  $g->SetGraphPadding(30, 30, 20, 15);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    17
  if ( get_class($g) == 'BarGraph' )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    18
  {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    19
    $g->SetBarPadding(7);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    20
    $g->SetBarFont(1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    21
    $g->SetBarDimensions(25, 7);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    22
  }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    23
  else if ( get_class($g) == 'LineGraph' )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    24
  {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    25
    $g->SetGraphAreaWidth(800);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    26
  }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    27
  $g->SetAxisDeepness(7);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    28
  $g->SetGraphTitleFont(2);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    29
  $g->SetGraphBackgroundTransparent(false, 240, 250, 255);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    30
  $g->SetGraphTransparency(25);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    31
  $g->SetAxisScaleColor(90, 90, 90);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    32
  $g->SetAxisScaleFont(1);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    33
  $g->SetScaleRoundY(0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    34
  $g->SetScaleRoundX(0);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    35
  $g->SetAxisStepSize(7);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    36
  return $g;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    37
}
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    38
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    39
// generate the data
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    40
// we're doing this by absolute hours, not by strictly "24 hours ago", e.g. on-the-hour stats
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    41
$mode = ( isset($_GET['mode']) ) ? $_GET['mode'] : 'lastday';
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    42
switch ( $mode )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    43
{
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    44
  case 'lastday':
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    45
  default:
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    46
    $g = makeGraph();
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    47
    $graph_title = $channel . ' message count - last 24 hours';
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    48
    $this_hour = gmmktime(gmdate('H'), 0, 0);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    49
    $graphdata = array();
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    50
    
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    51
    for ( $i = 23; $i >= 0; $i-- )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    52
    {
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    53
      $basetime = $this_hour - ( $i * 3600 );
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    54
      $ts = date('H:i', $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    55
      $basetime += 3600;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    56
      $graphdata[$ts] = stats_message_count($channel, 60, $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    57
    }
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    58
    break;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    59
  case 'lastweek':
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    60
    $g = makeGraph();
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    61
    $graph_title = $channel . ' activity - last 14 days';
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    62
    $this_day = gmmktime(0, 0, 0);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    63
    $graphdata = array();
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    64
    
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    65
    for ( $i = 13; $i >= 0; $i-- )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    66
    {
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    67
      $basetime = $this_day - ( $i * 86400 );
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    68
      $ts = date('D n/j', $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    69
      $basetime += 86400;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    70
      $graphdata[$ts] = stats_message_count($channel, 1440, $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    71
    }
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    72
    $g->SetBarPadding(12);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    73
    break;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    74
  case 'lastmonth':
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    75
    $g = makeGraph();
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    76
    $graph_title = $channel . ' activity - last 30 days';
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    77
    $this_day = gmmktime(0, 0, 0);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    78
    $graphdata = array();
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    79
    
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    80
    for ( $i = 29; $i >= 0; $i-- )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    81
    {
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    82
      $basetime = $this_day - ( $i * 86400 );
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    83
      $ts = date('Y-m-d', $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    84
      $basetime += 86400;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    85
      $graphdata[$ts] = stats_message_count($channel, 1440, $basetime);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    86
    }
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    87
    $g->SetBarPadding(15);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
    88
    break;
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    89
  case 'lasthour':
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    90
    $g = makeGraph('line');
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    91
    $g->SetAxisStepX(5);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    92
    $g->SetScaleFunctionX('lasthour_scaler');
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    93
    function lasthour_scaler($v, $g)
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    94
    {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    95
      $k = array_keys($g->data);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    96
      return ( isset($k[$v]) ) ? $k[$v] : 'now';
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    97
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    98
    $graph_title = $channel . ' activity - last hour';
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
    99
    $data = stats_raw_data($channel, 59);
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   100
    $agg = array();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   101
    foreach ( $data as $message )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   102
    {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   103
      $tid = intval(ltrim(date('i', $message['time']), '0'));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   104
      if ( !isset($agg[$tid]) )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   105
        $agg[$tid] = 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   106
      $agg[$tid]++;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   107
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   108
    $graphdata = array();
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   109
    $minutenow = intval(ltrim(date('i', NOW), '0'));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   110
    $hournow = intval(ltrim(date('H', NOW), '0'));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   111
    $hourthen = intval(ltrim(date('H', NOW-3600), '0'));
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   112
    for ( $i = $minutenow + 1; $i < 60; $i++ )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   113
    {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   114
      $istr = ( $i < 10 ) ? "0$i" : "$i";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   115
      $graphdata["$hourthen:$istr"] = ( isset($agg[$i]) ) ? $agg[$i] : 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   116
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   117
    for ( $i = 0; $i <= $minutenow; $i++ )
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   118
    {
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   119
      $istr = ( $i < 10 ) ? "0$i" : "$i";
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   120
      $graphdata["$hournow:$istr"] = ( isset($agg[$i]) ) ? $agg[$i] : 0;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   121
    }
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   122
    
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   123
    break;
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   124
}
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   125
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   126
$max = max($graphdata);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   127
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   128
// Determine axis interval
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   129
$interval = 2;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   130
if ( $max > 20 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   131
  $interval = 4;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   132
if ( $max > 25 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   133
  $interval = 5;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   134
if ( $max > 50 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   135
  $interval = 10;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   136
if ( $max > 200 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   137
  $interval = 40;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   138
if ( $max > 500 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   139
  $interval = 80;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   140
if ( $max > 1000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   141
  $interval = 100;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   142
if ( $max > 2000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   143
  $interval = 200;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   144
if ( $max > 3200 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   145
  $interval = 300;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   146
if ( $max > 4000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   147
  $interval = 500;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   148
if ( $max > 5000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   149
  $interval = 1000;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   150
if ( $max > 15000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   151
  $interval = 1500;
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   152
if ( $max > 30000 )
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   153
  $interval = round($max / 10);
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   154
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   155
$g->data = $graphdata;
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   156
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   157
$g->SetGraphTitle($graph_title);
43
ce2e9caf2dfa Added support for different types of graphs; added a last 60 minutes line graph
Dan
parents: 34
diff changeset
   158
$g->SetAxisStepY($interval);
34
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   159
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   160
$g->DrawGraph();
a8daa2016cf1 Added support for last month and last 2 weeks graphs; adjusted web interface accordingly
Dan
parents:
diff changeset
   161