From 1a0e9bd216ef26ac5db93b7189e355decd3163b8 Mon Sep 17 00:00:00 2001 From: Joe Pavitt Date: Tue, 10 Oct 2023 10:00:09 +0100 Subject: [PATCH] Better checking of x value before datetime assignment --- nodes/widgets/ui_chart.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nodes/widgets/ui_chart.js b/nodes/widgets/ui_chart.js index f8475dd0f..dee9ea061 100644 --- a/nodes/widgets/ui_chart.js +++ b/nodes/widgets/ui_chart.js @@ -38,7 +38,11 @@ module.exports = function (RED) { datapoint.y = payload } else if (typeof payload === 'object' && 'y' in payload) { // may have been given an x/y object already - datapoint.x = payload.x || (new Date()).getTime() + let x = payload.x + if (x === undefined || x === null) { + x = (new Date()).getTime() + } + datapoint.x = x datapoint.y = payload.y } return datapoint