-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph1_beta.php
166 lines (132 loc) · 4.39 KB
/
graph1_beta.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
include_once("bots.php");
$mylink = $wpdb->get_results("SELECT DATE(datetime) AS dates,AVG(sr) as response,AVG(secs) as seconds, STD(sr) as stdsr, STD(secs) as stdsecs FROM $table_name WHERE datetime between '$prevdate' and '$date' and secs<120 " . wphpc_get_useragent_exclusion() . wphpc_sql_where_country($country) . " GROUP BY dates"); // ORDER BY DAY(datetime) ASC");
?>
<br>
<canvas id="cvs_graph1" width="1200" height="250" >
[No canvas support]
</canvas>
<br>
<br>
<canvas id="cvs_graph1b" width="1200" height="250" >
[No canvas support]
</canvas>
<?php
$vals1="";
$labels1="";
$stddev="";
$stddev2="";
$vals2="";
foreach($mylink as $datas)
{
$dates = $datas->dates;
$newdate = date('M',strtotime($dates))."\\n".date('d',strtotime($dates)) ;
$responses = $datas->response;
$response = number_format($responses, 2, '.', '');
$secondss = $datas->seconds;
$seconds = number_format($secondss, 2, '.', '');
$stddev.=$datas->stdsr.",";
$stddev2.=$datas->stdsecs.",";
$vals1.=$response.",";
$vals2.=$seconds.",";
$labels1.="'".$newdate."',";
}
$vals1=rtrim($vals1,",");
$vals2=rtrim($vals2,",");
$labels1=rtrim($labels1,",");
$stddev= rtrim($stddev,",");
$stddev2= rtrim($stddev2,",");
?>
<script>
var central_line_data = [<?php echo $vals1; ?>];
var variance1 = [<?php echo $stddev; ?>];
var d1 = [];
var d2 = [];
for (var i=0; i<central_line_data.length; ++i) {
d1.push(central_line_data[i] + variance1[i]);
d2.push(central_line_data[i] - variance1[i]);
}
var line3 = new RGraph.Line({
id: 'cvs_graph1',
data: [d1, d2],
options: {
noxaxis: true,
textSize: 14,
filled: true,
filledRange: true,
fillstyle: 'rgba(0,0,255,0.2)',
colors: ['rgba(0,0,0,0)'],
linewidth: 3,
ylabels: false,
noaxes: true,
backgroundGrid: false,
hmargin: 5,
tickmarks: null,
textAccessible: true
}
}).draw();
var line4 = new RGraph.Line({
id: 'cvs_graph1',
data: central_line_data,
options: {
noxaxis: true,
textSize: 14,
backgroundGrid: false,
labels: [<?php echo $labels1; ?>],
tooltips: [<?php echo $labels1; ?>],
colors: ['blue'],
linewidth: 3,
numxticks: 11,
tickmarks: null,
hmargin: 5,
shadow: false,
textAccessible: true
}
}).draw();
var central_line_data2 = [<?php echo $vals2; ?>];
var variance2 = [<?php echo $stddev2; ?>];
var d3 = [];
var d4 = [];
for (var i=0; i<central_line_data2.length; ++i) {
d3.push(central_line_data2[i] + variance2[i]);
d4.push(central_line_data2[i] - variance2[i]);
}
var line3 = new RGraph.Line({
id: 'cvs_graph1b',
data: [d3, d4],
options: {
noxaxis: true,
textSize: 14,
filled: true,
filledRange: true,
fillstyle: 'rgba(0,0,255,0.2)',
colors: ['rgba(0,0,0,0)'],
linewidth: 3,
ylabels: false,
noaxes: true,
backgroundGrid: false,
hmargin: 5,
tickmarks: null,
textAccessible: true
}
}).draw();
var line4 = new RGraph.Line({
id: 'cvs_graph1b',
data: central_line_data2,
options: {
noxaxis: true,
textSize: 14,
backgroundGrid: false,
labels: [<?php echo $labels1; ?>],
tooltips: [<?php echo $labels1; ?>],
colors: ['blue'],
linewidth: 3,
numxticks: 11,
tickmarks: null,
hmargin: 5,
shadow: false,
textAccessible: true
}
}).draw();
</script>