|
|
@ -3,6 +3,7 @@ function moreInfo() { |
|
|
|
lineChart: {}, |
|
|
|
lineChart: {}, |
|
|
|
entityGroup: Alpine.store('entity').entityGroup, |
|
|
|
entityGroup: Alpine.store('entity').entityGroup, |
|
|
|
entityId: selectedEntityId || Alpine.store('entity').id, |
|
|
|
entityId: selectedEntityId || Alpine.store('entity').id, |
|
|
|
|
|
|
|
params: (this.entityGroup === 'POSEIDON' ? Alpine.store('entity').params.split(' ') : []), |
|
|
|
dopen: false, |
|
|
|
dopen: false, |
|
|
|
copen: false, |
|
|
|
copen: false, |
|
|
|
loading: false, |
|
|
|
loading: false, |
|
|
@ -97,11 +98,11 @@ function moreInfo() { |
|
|
|
}).render(grid); |
|
|
|
}).render(grid); |
|
|
|
}, |
|
|
|
}, |
|
|
|
drawDataChart() { |
|
|
|
drawDataChart() { |
|
|
|
|
|
|
|
delete this.lineChart; |
|
|
|
|
|
|
|
delete ctx; |
|
|
|
if (this.entityGroup !== 'POSEIDON') |
|
|
|
if (this.entityGroup !== 'POSEIDON') |
|
|
|
return; |
|
|
|
return; |
|
|
|
Alpine.store('entity').params.split(' ').forEach((param, idx) => { |
|
|
|
|
|
|
|
this.addCheckbox(param, idx); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
console.debug('drawing poseidon chart...'); |
|
|
|
console.debug('drawing poseidon chart...'); |
|
|
|
this.lineChart = {}; |
|
|
|
this.lineChart = {}; |
|
|
|
var ctx = document.getElementById('data-chart').getContext('2d'); |
|
|
|
var ctx = document.getElementById('data-chart').getContext('2d'); |
|
|
@ -114,108 +115,94 @@ function moreInfo() { |
|
|
|
.then(data => { |
|
|
|
.then(data => { |
|
|
|
Alpine.store('loading', false); |
|
|
|
Alpine.store('loading', false); |
|
|
|
console.debug("data poseidon: ", data); |
|
|
|
console.debug("data poseidon: ", data); |
|
|
|
let chartData = []; |
|
|
|
let chartData = {}; |
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
const labels = data.map(item => new Date(item.dt).toLocaleDateString('el-GR')); |
|
|
|
var item = data[i]; |
|
|
|
const values = data.map(item => item.val); |
|
|
|
chartData.push({ |
|
|
|
console.debug(labels); |
|
|
|
x: new Date(item.dt), |
|
|
|
console.debug(values); |
|
|
|
y: item.val |
|
|
|
chartData = { |
|
|
|
}); |
|
|
|
labels: labels, |
|
|
|
} |
|
|
|
datasets: [{ |
|
|
|
this.lineChart = new Chart( |
|
|
|
label: 'param', |
|
|
|
ctx, |
|
|
|
data: values |
|
|
|
{ |
|
|
|
}] |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
console.debug(chartData); |
|
|
|
|
|
|
|
this.lineChart = new Chart(ctx, { |
|
|
|
type: 'line', |
|
|
|
type: 'line', |
|
|
|
data: { |
|
|
|
data: chartData, |
|
|
|
labels: chartData.map(row => row.x), |
|
|
|
|
|
|
|
datasets: [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label: 'PARAM', |
|
|
|
|
|
|
|
data: chartData.map(row => row.y) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
options: { |
|
|
|
options: { |
|
|
|
scales: { |
|
|
|
scales: { |
|
|
|
xAxes: [{ |
|
|
|
xAxes: [{ |
|
|
|
type: 'time', |
|
|
|
type: 'time', |
|
|
|
time: { |
|
|
|
time: { |
|
|
|
unit: 'day' |
|
|
|
displayFormats: { |
|
|
|
} |
|
|
|
day: 'DD MMM YYYY' |
|
|
|
}] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
addCheckbox(type, index) { |
|
|
|
unit: 'day', |
|
|
|
var label = document.createElement('label'); |
|
|
|
stepSize: 20 |
|
|
|
var checkbox = document.createElement('input'); |
|
|
|
|
|
|
|
checkbox.type = 'checkbox'; |
|
|
|
|
|
|
|
checkbox.checked = (index === 0); |
|
|
|
|
|
|
|
checkbox.addEventListener('change', function() { |
|
|
|
|
|
|
|
this.lineChart.data.datasets[index].hidden = !checkbox.checked; |
|
|
|
|
|
|
|
this.lineChart.update(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
label.appendChild(checkbox); |
|
|
|
|
|
|
|
label.appendChild(document.createTextNode(type)); |
|
|
|
|
|
|
|
document.getElementById('checkbox-container').appendChild(label); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}] |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function poseidonChart(data) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var typeGroups = {}; |
|
|
|
|
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
|
|
|
|
var item = data[i]; |
|
|
|
|
|
|
|
if (!typeGroups[item.type]) { |
|
|
|
|
|
|
|
typeGroups[item.type] = []; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
typeGroups[item.type].push({ |
|
|
|
|
|
|
|
x: item.date, |
|
|
|
|
|
|
|
y: item.value |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var datasets = []; |
|
|
|
|
|
|
|
var index = 0; |
|
|
|
|
|
|
|
for (var type in typeGroups) { |
|
|
|
|
|
|
|
datasets.push({ |
|
|
|
|
|
|
|
label: type, |
|
|
|
|
|
|
|
data: typeGroups[type], |
|
|
|
|
|
|
|
borderColor: getRandomColor(), |
|
|
|
|
|
|
|
fill: false, |
|
|
|
|
|
|
|
hidden: false |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
addCheckbox(type, index++); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ctx = document.getElementById('myChart').getContext('2d'); |
|
|
|
|
|
|
|
var myChart = new Chart(ctx, { |
|
|
|
|
|
|
|
type: 'line', |
|
|
|
|
|
|
|
data: { |
|
|
|
|
|
|
|
datasets: datasets |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
options: { |
|
|
|
|
|
|
|
scales: { |
|
|
|
|
|
|
|
xAxes: [{ |
|
|
|
|
|
|
|
type: 'time', |
|
|
|
|
|
|
|
time: { |
|
|
|
|
|
|
|
unit: 'week' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
});} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// function poseidonChart(data) {
|
|
|
|
|
|
|
|
// var typeGroups = {};
|
|
|
|
|
|
|
|
// for (var i = 0; i < data.length; i++) {
|
|
|
|
|
|
|
|
// var item = data[i];
|
|
|
|
|
|
|
|
// if (!typeGroups[item.type]) {
|
|
|
|
|
|
|
|
// typeGroups[item.type] = [];
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// typeGroups[item.type].push({
|
|
|
|
|
|
|
|
// x: item.date,
|
|
|
|
|
|
|
|
// y: item.value
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// console.debug(typeGroups);
|
|
|
|
|
|
|
|
// this.params = typeGroups.type;
|
|
|
|
|
|
|
|
// var datasets = [];
|
|
|
|
|
|
|
|
// var index = 0;
|
|
|
|
|
|
|
|
// for (var type in typeGroups) {
|
|
|
|
|
|
|
|
// datasets.push({
|
|
|
|
|
|
|
|
// label: type,
|
|
|
|
|
|
|
|
// data: typeGroups[type],
|
|
|
|
|
|
|
|
// borderColor: getRandomColor(),
|
|
|
|
|
|
|
|
// fill: false,
|
|
|
|
|
|
|
|
// hidden: false
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// addCheckbox(type, index++);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// var ctx = document.getElementById('myChart').getContext('2d');
|
|
|
|
|
|
|
|
// var myChart = new Chart(ctx, {
|
|
|
|
|
|
|
|
// type: 'line',
|
|
|
|
|
|
|
|
// data: {
|
|
|
|
|
|
|
|
// datasets: datasets
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// options: {
|
|
|
|
|
|
|
|
// scales: {
|
|
|
|
|
|
|
|
// xAxes: [{
|
|
|
|
|
|
|
|
// type: 'time',
|
|
|
|
|
|
|
|
// time: {
|
|
|
|
|
|
|
|
// unit: 'week'
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
function getRandomColor() { |
|
|
|
function getRandomColor() { |
|
|
|
var letters = '0123456789ABCDEF'; |
|
|
|
var letters = '0123456789ABCDEF'; |
|
|
|