|
|
@ -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 |
|
|
|
{ |
|
|
|
}] |
|
|
|
type: 'line', |
|
|
|
}; |
|
|
|
data: { |
|
|
|
console.debug(chartData); |
|
|
|
labels: chartData.map(row => row.x), |
|
|
|
this.lineChart = new Chart(ctx, { |
|
|
|
datasets: [ |
|
|
|
type: 'line', |
|
|
|
{ |
|
|
|
data: chartData, |
|
|
|
label: 'PARAM', |
|
|
|
options: { |
|
|
|
data: chartData.map(row => row.y) |
|
|
|
scales: { |
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
options: { |
|
|
|
|
|
|
|
scales: { |
|
|
|
|
|
|
|
xAxes: [{ |
|
|
|
xAxes: [{ |
|
|
|
type: 'time', |
|
|
|
type: 'time', |
|
|
|
time: { |
|
|
|
time: { |
|
|
|
unit: 'day' |
|
|
|
displayFormats: { |
|
|
|
} |
|
|
|
day: 'DD MMM YYYY' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
unit: 'day', |
|
|
|
|
|
|
|
stepSize: 20 |
|
|
|
|
|
|
|
} |
|
|
|
}] |
|
|
|
}] |
|
|
|
} |
|
|
|
} |
|
|
|
}} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
addCheckbox(type, index) { |
|
|
|
|
|
|
|
var label = document.createElement('label'); |
|
|
|
|
|
|
|
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) { |
|
|
|
// function poseidonChart(data) {
|
|
|
|
|
|
|
|
// var typeGroups = {};
|
|
|
|
var typeGroups = {}; |
|
|
|
// for (var i = 0; i < data.length; i++) {
|
|
|
|
for (var i = 0; i < data.length; i++) { |
|
|
|
// var item = data[i];
|
|
|
|
var item = data[i]; |
|
|
|
// if (!typeGroups[item.type]) {
|
|
|
|
if (!typeGroups[item.type]) { |
|
|
|
// typeGroups[item.type] = [];
|
|
|
|
typeGroups[item.type] = []; |
|
|
|
// }
|
|
|
|
} |
|
|
|
// typeGroups[item.type].push({
|
|
|
|
typeGroups[item.type].push({ |
|
|
|
// x: item.date,
|
|
|
|
x: item.date, |
|
|
|
// y: item.value
|
|
|
|
y: item.value |
|
|
|
// });
|
|
|
|
}); |
|
|
|
// }
|
|
|
|
} |
|
|
|
//
|
|
|
|
|
|
|
|
// console.debug(typeGroups);
|
|
|
|
var datasets = []; |
|
|
|
// this.params = typeGroups.type;
|
|
|
|
var index = 0; |
|
|
|
// var datasets = [];
|
|
|
|
for (var type in typeGroups) { |
|
|
|
// var index = 0;
|
|
|
|
datasets.push({ |
|
|
|
// for (var type in typeGroups) {
|
|
|
|
label: type, |
|
|
|
// datasets.push({
|
|
|
|
data: typeGroups[type], |
|
|
|
// label: type,
|
|
|
|
borderColor: getRandomColor(), |
|
|
|
// data: typeGroups[type],
|
|
|
|
fill: false, |
|
|
|
// borderColor: getRandomColor(),
|
|
|
|
hidden: false |
|
|
|
// fill: false,
|
|
|
|
}); |
|
|
|
// hidden: false
|
|
|
|
addCheckbox(type, index++); |
|
|
|
// });
|
|
|
|
} |
|
|
|
// addCheckbox(type, index++);
|
|
|
|
|
|
|
|
// }
|
|
|
|
var ctx = document.getElementById('myChart').getContext('2d'); |
|
|
|
//
|
|
|
|
var myChart = new Chart(ctx, { |
|
|
|
// var ctx = document.getElementById('myChart').getContext('2d');
|
|
|
|
type: 'line', |
|
|
|
// var myChart = new Chart(ctx, {
|
|
|
|
data: { |
|
|
|
// type: 'line',
|
|
|
|
datasets: datasets |
|
|
|
// data: {
|
|
|
|
}, |
|
|
|
// datasets: datasets
|
|
|
|
options: { |
|
|
|
// },
|
|
|
|
scales: { |
|
|
|
// options: {
|
|
|
|
xAxes: [{ |
|
|
|
// scales: {
|
|
|
|
type: 'time', |
|
|
|
// xAxes: [{
|
|
|
|
time: { |
|
|
|
// type: 'time',
|
|
|
|
unit: 'week' |
|
|
|
// time: {
|
|
|
|
} |
|
|
|
// unit: 'week'
|
|
|
|
}] |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }]
|
|
|
|
} |
|
|
|
// }
|
|
|
|
});} |
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
function getRandomColor() { |
|
|
|
function getRandomColor() { |
|
|
|
var letters = '0123456789ABCDEF'; |
|
|
|
var letters = '0123456789ABCDEF'; |
|
|
|