-
Notifications
You must be signed in to change notification settings - Fork 0
/
charts.php
114 lines (103 loc) · 3.39 KB
/
charts.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
<?php
$arrD=array(
0 => 1,
1 => 2,
2 => 3,
3 => 4,
4 => 5,
5 =>6,
6 =>7);
require('database.php');
$connection=dbConnect();
//$sql="select count(id) from users where dateActive>=CURRENT_DATE-7; ";
//select DATE_FORMAT( CURRENT_DATE - 1, '%M %D, %Y' )
$arrD=array();
for($i=0;$i<7;$i++){
$arrD[]=$i+1;
}
$arrU=array();
for($i=0;$i<7;$i++){
$sql="select count(id) from users where dateActive=CURRENT_DATE-($i+1); ";
if($result=mysqli_query($connection,$sql)){
$row=mysqli_fetch_assoc($result);
$x=intVal($row['count(id)']);
$arrU[]=$x;
}
}
$arrF=array();
for($i=0;$i<7;$i++){
$sql="select count(id) from files where upload_date=CURRENT_DATE-($i+1); ";
$sql="select count(id) from transactions where fuploadDate=CURRENT_DATE-($i+1); ";
if($result=mysqli_query($connection,$sql)){
$row=mysqli_fetch_assoc($result);
$x=intVal($row['count(id)']);
$arrF[]=$x;
}
}
?>
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
//var arrDay=[1,2,3,4,5,6,7];
var arrDay=JSON.parse('<?php echo json_encode($arrD); ?>');
//var arrUsers=[10,2,4,8,12,6,5];
var arrUsers=JSON.parse('<?php echo json_encode($arrU); ?>');
//var arrFiles=[8,2,4,7,6,12,14];
var arrFiles=JSON.parse('<?php echo json_encode($arrF); ?>');
var arr=[];
arr[0]=['Day','Users','Files'];
for(var i=0;i<7;i++){
arr[i+1]=[arrDay[i],arrUsers[i],arrFiles[i]];
}
var data=google.visualization.arrayToDataTable(arr);
var options = {
curveType: 'function',
legend: { position: 'bottom' },
backgroundColor:{fill: '#212529',stroke:'blue',strokeWidth:2},
chartArea:{
backgroundColor:{
fill:'#2d3035',
stroke: 'black',
strokeWidth: 3
},
left:40,
right:40
},
colors: ['#9900ff','#ff5050'],
height:427,
width: 814,
lineWidth:1.5,
legend: {position: 'top',alignment:'center', textStyle: {color: '#b8b894', fontSize: 16}},
hAxis:{
//title: 'Day',
titleTextStyle: {
color: '#8a8d93',
bold:true
},
gridlines:{color:'transparent'},
baselineColor: 'black',
minValue:1
},
vAxis:{
//title: 'Number',
titleTextStyle: {
color: '#8a8d93',
bold:true
},
gridlines:{color:'transparent'},
baselineColor: 'black',
}
};
var chart = new google.visualization.ScatterChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 794px; height: 427px ; color:black"></div>
</body>
</html>