Skip to content

Fix bug with cumulative line #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
/ZonPHP/SEEHASE/
/ZonPHP/SEE/
/ZonPHP/SOLAR1/
/ZonPHP/SOLARTEST/
/ZonPHP/TILLY/
/ZonPHP/TIL/
/ZonPHP/.settings/
14 changes: 8 additions & 6 deletions ZonPHP/charts/day_chart.php
Original file line number Diff line number Diff line change
@@ -81,13 +81,14 @@
date("Y-m-d", strtotime($maxdag)) . "%' ORDER BY Datum_Dag, Naam ASC";
$resultmd = mysqli_query($con, $sqlmdinv) or die("Query failed. dag-max-dag " . mysqli_error($con));

if (mysqli_num_rows($resultmd) != 0) {
if (mysqli_num_rows($resultmd) > 0) {
while ($row = mysqli_fetch_array($resultmd)) {
$inverter_name = $row['Naam'];
$time_only = substr($row['Datum_Dag'], -9);
$today_max = $chartdatestring . $time_only; // current chart date string + max time
$today_max_utc = convertLocalDateTime($today_max); // date in UTC
$today_max_unix_utc = convertToUnixTimestamp($today_max_utc); // unix timestamp in UTC
$today_max_unix_utc = $today_max_unix_utc - ($today_max_unix_utc % 60); // round to nearest minute (skip seconds)
$allValuesMaxDay[$inverter_name][$today_max_unix_utc] = intval($row['gem']);
// remember first and last date
if ($max_first_val > $today_max_unix_utc) {
@@ -123,14 +124,14 @@
$inverterValues = $allValuesPerInverter[$inverter_name];

// loop over all times from all inverters from min to max
for ($time = $max_first_val; $time <= $max_last_val; $time += 300) {
for ($time = $max_first_val; $time <= $max_last_val; $time += 300) {
$currentInverterVal = "NaN";
$timeInMillis = $time * 1000;
if (isset($inverterValues[$time])) {
$currentInverterVal = $inverterValues[$time];
$cumSum += ($currentInverterVal / 12);
$cumDataString .= "{x: $timeInMillis, y: $cumSum},";
}
$cumDataString .= "{x: $timeInMillis, y: $cumSum},";
$dataSeriesString .= '{x:' . $timeInMillis . ', y: ' . $currentInverterVal . '},';
if (!isset($totalsumCumArray[$timeInMillis])) {
$totalsumCumArray[$timeInMillis] = 0;
@@ -310,7 +311,8 @@ function buildSubtitle(ctx) {
let dataZonPHP = data.dataZonPHP;
let txt = data.txt;
let totalValue = 0;
let lastDate = Date.now();
let lastDate = new Date();
lastDate = `${lastDate.getHours()}:${lastDate.getMinutes()}`;
let lastValue = 0;
let todayMax = 0;
let maxDay = Date.now();
@@ -359,9 +361,8 @@ function customDayLegendClick(e, legendItem, legend) {
cumSum = cloneAndResetY(dataset.dataCUM)
}
for (let ii in dataset.data) {

// cum
if (dataset.dataCUM[ii].y != null) {
if (dataset.dataCUM[ii] != null && dataset.dataCUM[ii].y != null) {
cumSum[ii].y = cumSum[ii].y + dataset.dataCUM[ii].y;
}
}
@@ -387,6 +388,7 @@ function customDayLegendClick(e, legendItem, legend) {
chart.options.plugins.subtitle = {
text: buildSubtitle(legend),
display: true,
padding: {top: 5, left: 0, right: 0, bottom: 3},
};
chart.update();
}
2 changes: 1 addition & 1 deletion ZonPHP/inc/header.php
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<meta name="keywords" content="ZonPHP,Sonne,Zon,sun PV, Photovoltaik, Datenlogger, SMA, Solar, Analyse">
<meta name="description" content="PV Anlagen Monitoring">
<meta name="author" content="seehase">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">

<?php
if ($params['autoReload'] > 0) {
2 changes: 1 addition & 1 deletion ZonPHP/inc/version_info.php
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
/********************************************************************
* Version
*********************************************************************/
$version = "v4.0.16";
$version = "v4.0.17";

// Change SessionId if needed e.g. if you run multi instances
$zonPHPSessionID = "SOLAR_" . str_replace('.', '_', $version);
2 changes: 1 addition & 1 deletion ZonPHP/validate.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
<meta name="keywords" content="ZonPHP,Sonne,Zon,sun PV, Photovoltaik, Datenlogger, SMA, Solar, Analyse">
<meta name="description" content="PV Anlagen Monitoring">
<meta name="author" content="seehase">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">

<title>ZonPHP Parameter Validation</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">