From 01b45f79b604a81c18f14b3e96999b9d6e2065af Mon Sep 17 00:00:00 2001 From: Joe Pavitt Date: Tue, 3 Oct 2023 10:14:27 +0100 Subject: [PATCH] Add clarity on multiple data point injection & on multi-line topic --- docs/nodes/widgets/ui-chart.md | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/nodes/widgets/ui-chart.md b/docs/nodes/widgets/ui-chart.md index 8ad520d0c..3d310e222 100644 --- a/docs/nodes/widgets/ui-chart.md +++ b/docs/nodes/widgets/ui-chart.md @@ -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}