Skip to content

Commit

Permalink
skip undefined label in chart legend
Browse files Browse the repository at this point in the history
  • Loading branch information
bartbutenaers authored Jan 27, 2025
1 parent 0d24e9d commit 6e5f5fa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ui/src/widgets/ui-chart/UIChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -385,21 +385,27 @@ export default {
const p = m.payload
const d = m._datapoint // server-side we compute a chart friendly format
const label = d.category
this.addPoints(p, d, label)
if (label !== null && label !== undefined) {
this.addPoints(p, d, label)
}
})
} else if (Array.isArray(payload) && msg.payload.length > 0) {
// we have received a message with an array of data points
// and should append each of them
payload.forEach((p, i) => {
const d = msg._datapoint ? msg._datapoint[i] : null // server-side we compute a chart friendly format where required
const label = d.category
this.addPoints(p, d, label)
if (label !== null && label !== undefined) {
this.addPoints(p, d, label)
}
})
} else if (payload !== null && payload !== undefined) {
// we have a single payload value and should append it to the chart
const d = msg._datapoint // server-side we compute a chart friendly format
const label = d.category
this.addPoints(msg.payload, d, label)
if (label !== null && label !== undefined) {
this.addPoints(msg.payload, d, label)
}
} else {
// no payload
console.log('have no payload')
Expand Down

0 comments on commit 6e5f5fa

Please sign in to comment.