|
|
@ -84,7 +84,7 @@ var configObject = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
shortcuts: 'hide',
|
|
|
|
shortcuts: 'hide',
|
|
|
|
endDate: currentDay,
|
|
|
|
endDate: currentDay,
|
|
|
|
|
|
|
|
maxDays: 2,
|
|
|
|
getValue: function () {
|
|
|
|
getValue: function () {
|
|
|
|
return this.value;
|
|
|
|
return this.value;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -112,28 +112,28 @@ $(document).ready(function () {
|
|
|
|
getDateTime(startDate.getTime(), endDate.getTime());
|
|
|
|
getDateTime(startDate.getTime(), endDate.getTime());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//hour picker
|
|
|
|
//hour
|
|
|
|
$('#hour-btn').on('click', function () {
|
|
|
|
$('#hour-btn').on('click', function () {
|
|
|
|
initDate();
|
|
|
|
initDate();
|
|
|
|
getDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
|
|
|
|
getDateTime(currentDay.getTime() - 3600000, currentDay.getTime());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//day picker
|
|
|
|
//12 hours
|
|
|
|
$('#today-btn').on('click', function () {
|
|
|
|
$('#h12-btn').on('click', function () {
|
|
|
|
initDate();
|
|
|
|
initDate();
|
|
|
|
getDateTime(currentDay.getTime() - 86400000, currentDay.getTime());
|
|
|
|
getDateTime(currentDay.getTime() - (3600000 * 12), currentDay.getTime());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//week picker
|
|
|
|
//24 hours
|
|
|
|
$('#week-btn').on('click', function () {
|
|
|
|
$('#h24-btn').on('click', function () {
|
|
|
|
initDate();
|
|
|
|
initDate();
|
|
|
|
getDateTime(currentDay.getTime() - 604800000, currentDay.getTime());
|
|
|
|
getDateTime(currentDay.getTime() - (3600000 * 24), currentDay.getTime());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//month picker
|
|
|
|
//48 hours
|
|
|
|
$('#month-btn').on('click', function () {
|
|
|
|
$('#h48-btn').on('click', function () {
|
|
|
|
initDate();
|
|
|
|
initDate();
|
|
|
|
getDateTime(currentDay.getTime() - (604800000 * 4), currentDay.getTime());
|
|
|
|
getDateTime(currentDay.getTime() - (3600000 * 48), currentDay.getTime());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('body').on('click', '.btn-group button', function (e) {
|
|
|
|
$('body').on('click', '.btn-group button', function (e) {
|
|
|
@ -315,9 +315,16 @@ function drawLineGraph(graphId, chartDataRaw) {
|
|
|
|
var chartData = [];
|
|
|
|
var chartData = [];
|
|
|
|
if (chartDataRaw[i].stats.length > 0) {
|
|
|
|
if (chartDataRaw[i].stats.length > 0) {
|
|
|
|
for (var j = 0; j < chartDataRaw[i].stats.length; j++) {
|
|
|
|
for (var j = 0; j < chartDataRaw[i].stats.length; j++) {
|
|
|
|
chartData.push({x: parseInt(chartDataRaw[i].stats[j].time), y: parseInt(chartDataRaw[i].stats[j].value)});
|
|
|
|
chartData.push({
|
|
|
|
|
|
|
|
x: parseInt(chartDataRaw[i].stats[j].time),
|
|
|
|
|
|
|
|
y: parseInt(chartDataRaw[i].stats[j].value)
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
graphConfig['series'].push({'color': color[k], 'data': chartData, 'name': chartDataRaw[i].device});
|
|
|
|
graphConfig['series'].push({
|
|
|
|
|
|
|
|
'color': color[k],
|
|
|
|
|
|
|
|
'data': summerize(chartData),
|
|
|
|
|
|
|
|
'name': chartDataRaw[i].device
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (++k == color.length) {
|
|
|
|
if (++k == color.length) {
|
|
|
|
k = 0;
|
|
|
|
k = 0;
|
|
|
@ -401,9 +408,16 @@ function drawBarGraph(graphId, chartDataRaw) {
|
|
|
|
var chartData = [];
|
|
|
|
var chartData = [];
|
|
|
|
if (chartDataRaw[i].stats.length > 0) {
|
|
|
|
if (chartDataRaw[i].stats.length > 0) {
|
|
|
|
for (var j = 0; j < chartDataRaw[i].stats.length; j++) {
|
|
|
|
for (var j = 0; j < chartDataRaw[i].stats.length; j++) {
|
|
|
|
chartData.push({x: parseInt(chartDataRaw[i].stats[j].time), y: parseInt(chartDataRaw[i].stats[j].value)});
|
|
|
|
chartData.push({
|
|
|
|
|
|
|
|
x: parseInt(chartDataRaw[i].stats[j].time),
|
|
|
|
|
|
|
|
y: parseInt(chartDataRaw[i].stats[j].value)
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
graphConfig['series'].push({'color': color[k], 'data': chartData, 'name': chartDataRaw[i].device});
|
|
|
|
graphConfig['series'].push({
|
|
|
|
|
|
|
|
'color': color[k],
|
|
|
|
|
|
|
|
'data': summerize(chartData),
|
|
|
|
|
|
|
|
'name': chartDataRaw[i].device
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (++k == color.length) {
|
|
|
|
if (++k == color.length) {
|
|
|
|
k = 0;
|
|
|
|
k = 0;
|
|
|
@ -470,11 +484,11 @@ function scaleGraphs() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Scale graphs
|
|
|
|
//Scale graphs
|
|
|
|
var sliderX = graphWidth * 60 * 60 / (toDate - fromDate);
|
|
|
|
var sliderX = graphWidth * 60 * 60000 / (toDate - fromDate);
|
|
|
|
if (sliderX < graphWidth) {
|
|
|
|
if (sliderX < graphWidth) {
|
|
|
|
// fake handle move
|
|
|
|
// fake handle move
|
|
|
|
if (sliderX < 100) {
|
|
|
|
if (sliderX < 50) {
|
|
|
|
sliderX = 100;
|
|
|
|
sliderX = 50;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var edown = document.createEvent("HTMLEvents");
|
|
|
|
var edown = document.createEvent("HTMLEvents");
|
|
|
|
edown.initEvent("mousedown", true, true);
|
|
|
|
edown.initEvent("mousedown", true, true);
|
|
|
@ -501,3 +515,19 @@ function convertDate(date) {
|
|
|
|
+ month + '-' + (('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '')
|
|
|
|
+ month + '-' + (('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '')
|
|
|
|
+ hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute;
|
|
|
|
+ hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function summerize(data) {
|
|
|
|
|
|
|
|
if (data.length > 1500) {
|
|
|
|
|
|
|
|
var nData = [];
|
|
|
|
|
|
|
|
var i = 1;
|
|
|
|
|
|
|
|
while (i < data.length) {
|
|
|
|
|
|
|
|
var t_avg = (data[i - 1].x + data[i].x) / 2;
|
|
|
|
|
|
|
|
var v_avg = (data[i - 1].y + data[i].y) / 2;
|
|
|
|
|
|
|
|
nData.push({x: t_avg, y: v_avg});
|
|
|
|
|
|
|
|
i += 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return summerize(nData);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|