Skip to content

Commit

Permalink
increment: PowerFox/PowerOpti Support added to PWA and Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
zoernert committed Apr 24, 2024
1 parent 059beca commit 1e495d3
Show file tree
Hide file tree
Showing 8 changed files with 905 additions and 120 deletions.
209 changes: 112 additions & 97 deletions framework/public_pwa/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,48 @@ const app = async function(token) {
}
const ctxChart = document.getElementById('forecastChart');
if(typeof window.chartObject !== 'undefined') window.chartObject.destroy();

window.chartObject = new Chart(ctxChart, {
type: 'bar',
data: {
labels: chartLabels,
datasets: [{
label: 'Preis je kWh',
data: chartData,
backgroundColor:chartColors
}]
},
options: {
scales: {
y: {
min: minY * 0.8
}
},
responsive: true,

plugins: {
tooltip: {
callbacks: {
label: function(context) {
return context.parsed.y.toFixed(2).replace('.',',') + ' €/kWh';
try {
window.chartObject = new Chart(ctxChart, {
type: 'bar',
data: {
labels: chartLabels,
datasets: [{
label: 'Preis je kWh',
data: chartData,
backgroundColor:chartColors
}]
},
options: {
scales: {
y: {
min: minY * 0.8
}
},
responsive: true,

plugins: {
tooltip: {
callbacks: {
label: function(context) {
return context.parsed.y.toFixed(2).replace('.',',') + ' €/kWh';
}
}
},
legend: {
display:false
},
datalabels: {
display: false,
}
}
},
legend: {
display:false
},
datalabels: {
display: false,
}
}
}
});
});

} catch(e) {

}
});

let crossbalance = '';

if($.urlParam("crossbalance") || window.crossbalance) {
Expand Down Expand Up @@ -243,76 +248,86 @@ const app = async function(token) {
const xValues = consumptionChart.map(point => new Date( (point.x * 3600000)-demofy ).toLocaleString());
const yValues = consumptionChart.map(point => (point.y/1000));
const yValues2 = costChart.map(point => point.y);

window.timelineChartObject = new Chart(ctxTimelineChart, {
type: 'line',
data: {
labels: xValues, // x-Werte als Labels
datasets: [{
label: 'kWh',
yAxisID: 'A',
data: yValues, // y-Werte für die Datenpunkte
borderWidth: 1,
backgroundColor: '#273469',
borderColor: '#273469',
tension: 0.1 // Glättung der Linie
},{
label: '€',
yAxisID: 'B',
data: yValues2, // y-Werte für die Datenpunkte
borderWidth: 1,
backgroundColor: '#606060',
borderColor: '#606060',
tension: 0.1 // Glättung der Linie
}]
},
options: {
responsive: true,
scales: {
A: {
type: 'linear',
position: 'left',
ticks: { beginAtZero: true, color: '#273469' },
// Hide grid lines, otherwise you have separate grid lines for the 2 y axes
grid: { display: false }
},
B: {
type: 'linear',
position: 'right',
ticks: { beginAtZero: true, color: '#606060' },
grid: { display: false }
},
x: { ticks: { beginAtZero: true } }

if(xValues.length > 1) {
window.timelineChartObject = new Chart(ctxTimelineChart, {
type: 'line',
data: {
labels: xValues, // x-Werte als Labels
datasets: [{
label: 'kWh',
yAxisID: 'A',
data: yValues, // y-Werte für die Datenpunkte
borderWidth: 1,
backgroundColor: '#273469',
borderColor: '#273469',
tension: 0.1 // Glättung der Linie
},{
label: '€',
yAxisID: 'B',
data: yValues2, // y-Werte für die Datenpunkte
borderWidth: 1,
backgroundColor: '#606060',
borderColor: '#606060',
tension: 0.1 // Glättung der Linie
}]
},
plugins: {
zoom: {
pan: {
mode: 'x',
enabled: true
},
options: {
responsive: true,
scales: {
A: {
type: 'linear',
position: 'left',
ticks: { beginAtZero: true, color: '#273469' },
// Hide grid lines, otherwise you have separate grid lines for the 2 y axes
grid: { display: false }
},
B: {
type: 'linear',
position: 'right',
ticks: { beginAtZero: true, color: '#606060' },
grid: { display: false }
},
x: { ticks: { beginAtZero: true } }
},
plugins: {
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true
pan: {
mode: 'x',
enabled: true
},
mode: 'x',
}
},
datalabels: {
display: false,
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true
},
mode: 'x',
}
},
datalabels: {
display: false,
}
}

}

}
});
setTimeout(function() {
window.timelineChartObject.zoom( 2-(1/(timeSpan/86400000)) );
});
setTimeout(function() {
window.timelineChartObject.pan({x: -timeSpan});
},100);
},500);
try {
window.timelineChartObject.zoom( 2-(1/(timeSpan/86400000)) );
setTimeout(function() {
try {
window.timelineChartObject.pan({x: -timeSpan});
} catch(e) {

}
},500);
} catch(e) {

}
},1500);
}

// prepare Stats
let htmlCost = '<table class="table table-condensed">';
Expand Down
Loading

0 comments on commit 1e495d3

Please sign in to comment.