Skip to content

Commit

Permalink
Merge pull request #256 from FlowFuse/145-chart-x-0
Browse files Browse the repository at this point in the history
Better checking of x value before datetime assignment
  • Loading branch information
joepavitt authored Oct 10, 2023
2 parents 9005e0f + 1a0e9bd commit d4f9f10
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 d4f9f10

Please sign in to comment.