forked from ayushagarwalk/accgen-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stats.html
135 lines (134 loc) · 4.62 KB
/
stats.html
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
<html>
<head>
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-137480510-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-137480510-1');
</script>
</head>
<script src="https://www.amcharts.com/lib/4/core.js">
</script>
<script src="https://www.amcharts.com/lib/4/charts.js">
</script>
<script src="https://www.amcharts.com/lib/4/themes/dark.js">
</script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js">
</script>
<div id="chartdiv">
</div>
<div id="chartdiv2">
</div>
<script>
httpGetAsync("https://schoolproj.cloudaccess.host/json.php",load);
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true);
// true for asynchronous
xmlHttp.send(null);
}
function load(data)
{
// Themes begin
am4core.useTheme(am4themes_dark);
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart
var chart = am4core.create("chartdiv", am4charts.XYChart);
chart.paddingRight = 20;
chart.data = generateChartData();
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.baseInterval = {
"timeUnit": "minute",
"count": 1
};
dateAxis.tooltipDateFormat = "HH:mm, d MMMM";
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.tooltip.disabled = true;
valueAxis.title.text = "Number of Accounts Generated";
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.dateX = "date";
series.dataFields.valueY = "generated";
series.tooltipText = "Generated: [bold]{valueY}[/]";
series.fillOpacity = 0.3;
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.dateX = "date";
series.dataFields.valueY = "taken";
series.tooltipText = "Taken: [bold]{valueY}[/]";
chart.cursor = new am4charts.XYCursor();
chart.cursor.lineY.opacity = 0;
chart.scrollbarX = new am4charts.XYChartScrollbar();
chart.scrollbarX.series.push(series);
// Create chart
var chart = am4core.create("chartdiv2", am4charts.XYChart);
chart.paddingRight = 20;
chart.data = generateChartData2();
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.baseInterval = {
"timeUnit": "minute",
"count": 1
};
dateAxis.tooltipDateFormat = "HH:mm, d MMMM";
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.tooltip.disabled = true;
valueAxis.title.text = "Number of Accounts Taken";
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.dateX = "date";
series.dataFields.valueY = "generated";
series.tooltipText = "Generated: [bold]{valueY}[/]";
series.fillOpacity = 0.3;
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.dateX = "date";
series.dataFields.valueY = "taken";
series.tooltipText = "Taken: [bold]{valueY}[/]";
chart.cursor = new am4charts.XYCursor();
chart.cursor.lineY.opacity = 0;
chart.scrollbarX = new am4charts.XYChartScrollbar();
chart.scrollbarX.series.push(series);
function generateChartData2() {
var chartData = [];
var arr = JSON.parse(data);
arr.forEach(function(element) {
chartData.push({
date: new Date(element.date+"Z"), taken: element.taken /*, taken: element.taken*/ }
);
}
);
return chartData;
}
function generateChartData() {
var chartData = [];
var arr = JSON.parse(data);
arr.forEach(function(element) {
chartData.push({
date: new Date(element.date+"Z"), generated: element.generated /*, taken: element.taken*/ }
);
}
);
return chartData;
}
}
</script>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
body {
background-color: #30303d;
color: #fff;
}
#chartdiv {
width: 100%;
height: 500px;
}
</style>
</html>