-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
186 lines (168 loc) · 4.9 KB
/
index.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ilość czasu w czasie.</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<script src="GeneratedChartData.js" type "text/javascript"></script>
<script>
var check1;
var check2;
if (check1 != 1 || check2 != 1) document.getElementById("loadInfo").innerHTML = "Problem Loading. Please refresh.";
var chart;
var loadAbs = 1;
var displayData = [];
var accMul = 1000;
var loadHourly = 0;
function loadChart()
{
generateChartData();
var lastDate = new Date(displayData[displayData.length - 1]["date"]);
document.getElementById("dateDisplay").innerHTML = lastDate.toString();
chart = new AmCharts.AmSerialChart();
chart.dataProvider = displayData;
chart.categoryField = "date";
chart.addListener("dataUpdated", zoomChart);
chart.synchronizeGrid = true;
var categoryAxis = chart.categoryAxis;
categoryAxis.parseDates = true;
categoryAxis.minPeriod = "mm";
categoryAxis.minorGridEnabled = true;
categoryAxis.axisColor = "#DADADA";
categoryAxis.twoLineMode = true;
categoryAxis.dateFormats = [{
period: 'fff',
format: 'JJ:NN:SS'
}, {
period: 'ss',
format: 'JJ:NN:SS'
}, {
period: 'mm',
format: 'JJ:NN'
}, {
period: 'hh',
format: 'JJ:NN'
}, {
period: 'DD',
format: 'DD'
}, {
period: 'WW',
format: 'DD'
}, {
period: 'MM',
format: 'MMM'
}, {
period: 'YYYY',
format: 'YYYY'
}];
var valueAxis1 = new AmCharts.ValueAxis();
valueAxis1.axisColor = "#44AA00";
if (loadHourly == 1) valueAxis1.unit = "h";
valueAxis1.axisThickness = 2;
chart.addValueAxis(valueAxis1);
var bulletTypes = ["round", "square", "triangleUp", "triangleDown", "triangleLeft", "triangleRight", "bubble", "diamond"];
for (var i = 0; i < titles.length; i++)
{
var graph = new AmCharts.AmGraph();
graph.valueAxis = valueAxis1;
graph.title = titles[i];
graph.valueField = "val" + titles[i];
graph.bullet = bulletTypes[i % bulletTypes.length];
graph.hideBulletsCount = 200;
graph.bulletBorderThickness = 1;
chart.addGraph(graph);
}
var chartCursor = new AmCharts.ChartCursor();
chartCursor.cursorAlpha = 0.1;
chartCursor.fullWidth = true;
chartCursor.valueLineBalloonEnabled = true;
chart.addChartCursor(chartCursor);
var chartScrollbar = new AmCharts.ChartScrollbar();
chart.addChartScrollbar(chartScrollbar);
var legend = new AmCharts.AmLegend();
legend.marginLeft = 110;
legend.useGraphSettings = true;
chart.addLegend(legend);
chart.write("chartdiv");
}
AmCharts.ready(function() {
loadChart();
});
function generateChartData()
{
chartData.sort(function(a, b) {
return new Date(a.date) - new Date(b.date)
});
displayData = JSON.parse(JSON.stringify(chartData));
for (var i = 0; i < titles.length; i++)
{
var title = titles[i];
var mn = Infinity;
for (var j = 0; j < displayData.length; j++)
{
if ("val" + title in displayData[j])
{
if (loadHourly) displayData[j]["val" + title] = parseFloat(displayData[j]["val" + title]) * 24;
if (parseFloat(displayData[j]["val" + title]) < mn)
{
mn = parseFloat(displayData[j]["val" + title]);
}
}
}
if (loadAbs == 1)
{
for (var j = 0; j < displayData.length; j++)
{
if ("val" + title in displayData[j])
{
displayData[j]["val" + title] = parseFloat(displayData[j]["val" + title]) - mn;
}
}
}
for (var j = 0; j < displayData.length; j++)
{
if ("val" + title in displayData[j])
{
displayData[j]["val" + title] = Math.round(parseFloat(displayData[j]["val" + title]) * accMul) / accMul;
}
}
}
}
function zoomChart()
{
chart.zoomToIndexes(-Infinity, Infinity);
}
function changeAbsolute()
{
loadAbs ^= 1;
loadChart();
document.getElementById('loadInfo').innerHTML = "Changed absolute.";
}
function changeHourly()
{
loadHourly ^= 1;
if (loadHourly == 1)
{
accMul = 100;
document.getElementById('unitDisplay').innerHTML = "Hour ";
}
else
{
accMul = 1000;
document.getElementById('unitDisplay').innerHTML = "Days ";
}
loadChart();
document.getElementById('loadInfo').innerHTML = "Changed hourly.";
}
</script>
</head>
<body>
<div id="chartdiv" style="width: 100%; height: 600px;"></div>
<a id="unitDisplay">Days </a><a id="dateDisplay"></a><br>
<button type="button" onclick="{changeAbsolute();}">Change if absolute.</button>
<button type="button" onclick="{changeHourly();}">Change if days or hours.</button><br>
<a id="loadInfo">Nothing.</a>
</body>
</html>