X-Axis Limit not respected using X-Axis Type Timescale
Current Behavior
I have two charts that use the same data (1 week of data) but one is intended to show only 1 day and the other 1 week. I set the limits in the "X-Axis Limit" field:
but the 1-day limit does not work, it shows 1 week of data (all the data available in the base data). Daily data on the left, weekly on the right:
Expected Behavior
The time limits should be respected, and the chart with 1 day limit should show just 1 day worth of data.
Steps To Reproduce
- Get 1 week data
- Create 2 time charts, 1 showing only one day, the other 1 week of data
- Display the charts
Environment
- Dashboard version: 1.28.0
- Node-RED version: 4.1.0
- Node.js version: 20.19.4
- npm version: 10.8.2
- Platform/OS: Nodered on Docker (https://hub.docker.com/r/nodered/node-red)
- Browser: Chrome
Have you provided an initial effort estimate for this issue?
I can not provide an initial effort estimate
The time range limit only works when adding samples onto an existing chart. If you send it a batch in one go it will show them all. Try using a Split node to split the array into individual messages before feeding to the chart, though I not going to guarantee that will do it.
Or send it an extra message with an empty payload after sending the batch may do it.
In fact it seems you are correct, even when new data are added the old points are not removed from the chart unless the page is refreshed. This is true for 1.27.0 up to 1.29.0
The time range limit only works when adding samples onto an existing chart. If you send it a batch in one go it will show them all. Try using a Split node to split the array into individual messages before feeding to the chart, though I not going to guarantee that will do it.
Ok, thanks. The documentation says nothing about this behavior, so I thought the limit was applied in every case. I will try another approach, as splitting into thousands of individual messages to apply the limit seems overkill in this case.
I have submitted PR #1906 which should fix issue #1905, ie when data is added to a chart in append mode then, currently, data older than the configured time limit is not removed.
@aalvarell if you add the data to the chart in Append mode, then, if this PR is accepted, the next release of node-red will behave as you expected, in that after sending the data to the chart, data older than the configured time (relative to the current time) will be removed from the chart.
I have submitted PR #1906 which should fix issue #1905, ie when data is added to a chart in append mode then, currently, data older than the configured time limit is not removed.
@aalvarell if you add the data to the chart in Append mode, then, if this PR is accepted, the next release of node-red will behave as you expected, in that after sending the data to the chart, data older than the configured time (relative to the current time) will be removed from the chart.
Perfect, thank you!
It would be desirable to indicate in the documentation that the X-Axis limit only works with Action="Append", not with Action="Replace", or to disable the X-Axis limit field when "Replace" Action is selected.
I accidentally closed the issue, sorry...
It would be desirable to indicate in the documentation that the X-Axis limit only works with Action="Append", not with Action="Replace",
In fact the PR does not work like that, I changed my mind on how it should work. The limit will be applied whatever mode is used. The ability to disable the limit completely has been added by allowing it to be set to 0.