8
|
1 |
<?php
|
|
2 |
|
|
3 |
require('../stats-fe.php');
|
|
4 |
require('../graphs.php');
|
|
5 |
require('../timezone.php');
|
|
6 |
|
|
7 |
$first_channel = array_keys($stats_data['messages']);
|
|
8 |
$first_channel = $first_channel[0];
|
|
9 |
$channel = ( isset($_REQUEST['channel']) && isset($stats_data['messages'][$_REQUEST['channel']]) ) ? $_REQUEST['channel'] : $first_channel;
|
|
10 |
|
|
11 |
// generate the data
|
|
12 |
// we're doing this by absolute hours, not by strictly "24 hours ago", e.g. on-the-hour stats
|
|
13 |
$this_hour = gmmktime(gmdate('H'), 0, 0);
|
|
14 |
$graphdata = array();
|
|
15 |
|
|
16 |
for ( $i = 23; $i >= 0; $i-- )
|
|
17 |
{
|
|
18 |
$basetime = $this_hour - ( $i * 3600 );
|
|
19 |
$ts = date('H:i', $basetime);
|
|
20 |
$basetime += 3600;
|
|
21 |
$graphdata[$ts] = stats_message_count($channel, 60, $basetime);
|
|
22 |
}
|
|
23 |
|
|
24 |
$max = max($graphdata);
|
|
25 |
|
|
26 |
// Determine axis interval
|
|
27 |
$interval = 2;
|
|
28 |
if ( $max > 20 )
|
|
29 |
$interval = 4;
|
|
30 |
if ( $max > 25 )
|
|
31 |
$interval = 5;
|
|
32 |
if ( $max > 50 )
|
|
33 |
$interval = 10;
|
|
34 |
if ( $max > 200 )
|
|
35 |
$interval = 40;
|
|
36 |
if ( $max > 500 )
|
|
37 |
$interval = 80;
|
|
38 |
if ( $max > 1000 )
|
|
39 |
$interval = 100;
|
|
40 |
if ( $max > 2000 )
|
|
41 |
$interval = 200;
|
|
42 |
if ( $max > 5000 )
|
|
43 |
$interval = 1000;
|
|
44 |
if ( $max > 15000 )
|
|
45 |
$interval = 1500;
|
|
46 |
if ( $max > 30000 )
|
|
47 |
$interval = round($max / 10);
|
|
48 |
|
|
49 |
$g = new GraphMaker(); // _Compat();
|
|
50 |
|
|
51 |
$g->SetGraphPadding(20, 30, 20, 15);
|
|
52 |
$g->SetGraphAreaHeight(200);
|
|
53 |
$g->SetBarPadding(10);
|
|
54 |
$g->SetBarData($graphdata);
|
|
55 |
$g->SetGraphBackgroundTransparent(240, 250, 255, 0);
|
|
56 |
$g->SetGraphTransparency(25);
|
|
57 |
$g->SetAxisStep($interval);
|
|
58 |
$g->SetGraphTitle($channel . ' message count - last 24 hours');
|
|
59 |
|
|
60 |
$g->DrawGraph();
|