Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions nodes/widgets/ui_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ module.exports = function (RED) {
const ago = (removeOlder * removeOlderUnit) * 1000 // milliseconds ago
const cutOff = (new Date()).getTime() - ago
const filterFn = (msg) => {
let timestamp = msg._datapoint.x
// msg._datapoint may be a single point or, in the case of multiple series in one msg, an array
// if it is an array then all the elements will have the same timestamp so use the first one
let timestamp = Array.isArray(msg._datapoint) ? msg._datapoint[0].x : msg._datapoint.x
// is x already a millisecond timestamp?
if (typeof (msg._datapoint.x) === 'string') {
timestamp = (new Date(msg._datapoint.x)).getTime()
if (typeof (timestamp) === 'string') {
timestamp = (new Date(timestamp)).getTime()
}
return timestamp > cutOff
}
Expand Down
9 changes: 2 additions & 7 deletions ui/src/widgets/ui-chart/UIChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,8 @@
// determine what type of msg we have
if (Array.isArray(msg) && msg.length > 0) {
// we have received an array of messages (loading from stored history)
msg.forEach((m, i) => {
const p = m.payload
const d = m._datapoint // server-side we compute a chart friendly format
const label = d.category
if (label !== null && label !== undefined) {
this.addPoints(p, d, label, options)
}
msg.forEach((m) => {
this.add(m)
})
} else if (Array.isArray(payload) && msg.payload.length > 0) {
// we have received a message with an array of data points
Expand Down Expand Up @@ -748,10 +743,10 @@
updateYAxisLimits (options) {
if (this.hasData && this.props.xAxisType !== 'radial') {
if (!Object.hasOwn(this.props, 'ymin') || this.props.ymin === '' || typeof this.props.ymin === 'undefined') {
options.yAxis[0].min = axisHelper.getAxisMin // set sensible y-limits

Check warning on line 746 in ui/src/widgets/ui-chart/UIChart.vue

View workflow job for this annotation

GitHub Actions / build / Build on 20

Caution: `axisHelper` also has a named export `getAxisMin`. Check if you meant to write `import {getAxisMin} from './helpers/axis.helper'` instead
}
if (!Object.hasOwn(this.props, 'ymax') || this.props.ymax === '' || typeof this.props.ymax === 'undefined') {
options.yAxis[0].max = axisHelper.getAxisMax // set sensible y-limits

Check warning on line 749 in ui/src/widgets/ui-chart/UIChart.vue

View workflow job for this annotation

GitHub Actions / build / Build on 20

Caution: `axisHelper` also has a named export `getAxisMax`. Check if you meant to write `import {getAxisMax} from './helpers/axis.helper'` instead
}
}
},
Expand Down
Loading