Skip to content

Commit

Permalink
Better checking of x value before datetime assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
joepavitt committed Oct 10, 2023
1 parent 9005e0f commit 1a0e9bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nodes/widgets/ui_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a0e9bd

Please sign in to comment.