Repository navigation
fix(ui-chart): honour msg y-axis property for number/string payloads - #2393
pcbeingused333 wants to merge 10 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
This does fix the issue in the test flow I posted, but the change makes decisions on what is in msg.payload and the error is not related to the value in msg.payload. If the posted flow is changed slightly to Delete msg.payload then again no data are plotted. |
This is the fundamental error here. It should just read something like: |
…payload When y is configured as a msg property, use it for a single (non-array) value whether msg.payload is a number, a string or absent, instead of deciding by the payload's type. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @colinl, you were right and my first follow-up was incomplete: it only fixed the This comment was drafted with AI assistance (Claude Code); the change was tested by running |
|
The function |
addToChart is a low-level helper and should not read config or msg to override the value it is given. Resolve the configured msg y property in beforeSend and pass it in.
|
Thanks @colinl, that makes sense. This comment was drafted with AI assistance (Claude Code); the change was tested by running |
|
In the test flow in the issue, if msg.payload is set to an object then addToChart() is called with that object in the first parameter. Is that intended? Somehow the correct value does end up getting added to the chart, but not from that parameter. I do not understand why, if the value to plot is in msg.someProperty, that msg.payload is being tested to see if it is an object. Also the new function isDataMsg returns true if msg.payload is present. However, if the value to be charted is coming from, for example, msg.value then the value of msg.payload is irrelevant. If msg.value is not present then it is not a data message whatever the value of msg.payload. |
…not msg.payload Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @colinl. On the first point: you're right that the object case shouldn't be left out. With Y set to a msg property, On This comment was drafted with AI assistance (Claude Code); the change was tested by running |
It is perfectly valid to have chart data and msg.ui_update in the same message.
I think that possibly, if a message property is specified for the data, then the empty array should be sent to that property rather than msg.payload to clear the chart. What do you think? |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @colinl. Agreed on On clearing: sending the empty array to the configured property (e.g. This comment was drafted with AI assistance (Claude Code); the change was tested by running |
|
Why does isDataMsg() always return true if msg.payload is an array, even if msg.payload is not the source of the data t be plotted? I am having difficulty working out why the new override parameter is necessary in addToChart, can you explain the logic please? |
|
Another issue. If Y is set to msg.value.y then ui_update messages do not appear to be getting through to the chart. It is ok if Y is msg.value. |
|
Thanks, Colin. The array exception in The override was intended to let an object payload supply X and series while getting Y from the configured message property. The object path already reads that property, so the override was redundant and has been removed. The array path already processes the payload separately, which also makes the explicit array check in For This reply was drafted with AI assistance. |
|
I thought we might be there at last, but charts where the series is defined by JSON seem to be messed up. This flow doesn't plot anything. Everything else that I have tested appears to be ok. |
…grams Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Thanks @colinl. The JSON-series flow plotted nothing because the new data check required a value at the Y property ( This reply was drafted with AI assistance. |
Should the flow not have tested before committing the changes? |
|
Yes, it should have been, sorry. It has now been run in a headless Chromium against 695145a: your multi-series flow plots both This reply was drafted with AI assistance, and the browser check was run by the AI agent. |
|
Excellent, all of my test flows appear to work correctly now. @n-lark I think we need a decision as to what message should clear the chart. Currently
The question is, in each of those cases, where one should send the empty array to clear the chart? |
Fixes #2392
When Y is configured as a message property, the chart uses that property for Y. A missing parent in a nested path such as
msg.value.yis handled as absent chart data so a message carryingui_updatestill reaches the client.An empty
msg.payloadarray remains the chart's clear command, including when the configured Y property is absent. The regression test seeds chart history, sends the clear command through the node, and checks that history is empty and that the socket message carries an empty datapoint array.All 11 tests in
test/nodes/widgets/ui_chart.spec.jspassed.Changes and description were prepared with AI assistance.