-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.php
More file actions
38 lines (38 loc) · 1.17 KB
/
graph.php
File metadata and controls
38 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php if ( !defined( 'STUZZPANEL' ) ) exit; ?>
<?php $first = false; foreach ( array( 'players', 'cpumem', 'tickrate' ) as $graph ) { if ( $first ) $first = false; else echo '<hr>'; ?>
<div id="graph-<?php echo $graph; ?>" style="width: 600px; height: 300px;"></div>
<?php } ?>
<script async>
$( 'a[href="#graph"]' ).click(function() {
$.getJSON( 'index.php?api=graph&key=' + $( '#req_key' ).val(), function( data ) {
$.each( data, function( graph, lines ) {
var data = new google.visualization.DataTable();
data.addColumn( 'date', 'Date' );
var count = 0;
$.each( lines, function( line, points ) {
data.addColumn( 'number', line );
if ( !count ) {
for ( var i in points ) {
count++;
}
}
});
data.addRows( count );
var i = 0;
$.each( lines, function( line, points ) {
var j = 0;
$.each( points, function( point, value ) {
if ( !i ) {
data.setValue( j, 0, new Date( point * 1000 ) );
}
data.setValue( j, i + 1, value );
j++;
} );
i++;
} );
var chart = new google.visualization.AnnotatedTimeLine( document.getElementById( 'graph-' + graph ) );
chart.draw( data, {} );
} );
} );
} );
</script>