Skip to content

Commit

Permalink
Merge pull request #231 from FlowFuse/docs-chart-array
Browse files Browse the repository at this point in the history
Add clarity on multiple data point injection &  on multi-line topic
  • Loading branch information
joepavitt authored Oct 3, 2023
2 parents 44d57a3 + 01b45f7 commit 67c61d4
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions docs/nodes/widgets/ui-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,42 @@ Line Charts accept a variety of payload formats. The following are all valid:

If you would like to plot multiple lines on the same chart, you can do so by including a `msg.topic` alongside the relevant `msg.payload`, e.g:

```json
{
```js
msg = {
"topic": "line-1",
"payload": 1
}
```

```json
{
```js
msg = {
"topic": "line-2",
"payload": 2
}
```

#### Multiple Data Points (Injecting an Array of Data)

If you would like to pass in multiple data points at the same time into a chart, you can do so by passing an `Array` in `msg.payload`.

```js
msg = {
"topic": "line-1",
"payload": [{
x: 30,
y: 43
}, {
x: 40,
y: 56
}, {
x: 50,
y: 74
}]
}
```

Note how we can still define the `msg.topic` value such that these data points all appear on the same line.

### Scatter Plot

![Example of a Scatter Plot](/images/node-examples/ui-chart-scatter.png "Example of a Scatter Plot"){data-zoomable}
Expand Down

0 comments on commit 67c61d4

Please sign in to comment.