Skip to content

Commit 18ba765

Browse files
committed
api: break line charts at data gaps instead of interpolating
The history line charts filtered out null points, so Chart.js saw contiguous data and drew a straight line across gaps (e.g. when the collector had no data, or after a MariaDB outage). Keep null points in the data array and set spanGaps:false so the line breaks at gaps instead of connecting across them.
1 parent 23fd215 commit 18ba765

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎api/static/index.html‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ <h3 id="rule-editor-title">Edit Rule</h3>
710710
const rows = res.snapshots || [];
711711
const mk = (label, field, color, fill=true) => ({
712712
label,
713-
data: rows.map(r => r.registers[field] != null ? {x:r.timestamp, y:r.registers[field]} : null).filter(p => p),
713+
data: rows.map(r => r.registers[field] != null ? {x:r.timestamp, y:r.registers[field]} : null),
714+
spanGaps: false,
714715
borderColor: color, backgroundColor: color + (fill?'33':''), fill, tension:0.2, pointRadius:0
715716
});
716717
createLineChart('chart-pv-today', [mk('PV1','pv1_power','#eab308'), mk('PV2','pv2_power','#facc15')]);
@@ -731,7 +732,8 @@ <h3 id="rule-editor-title">Edit Rule</h3>
731732
const c = r.registers['charge_power'];
732733
if (d == null && c == null) return null;
733734
return { x: r.timestamp, y: (d || 0) - (c || 0) };
734-
}).filter(p => p),
735+
}),
736+
spanGaps: false,
735737
borderColor: '#22c55e', backgroundColor: '#22c55e', fill: false, tension: 0.2, pointRadius: 0
736738
};
737739
createLineChart('chart-battery-power', [batPower]);

0 commit comments

Comments
 (0)