joBr99 / nspanel-lovelace-ui

Custom Firmware for NsPanel with the design of HomeAssistant's lovelace UI in mind, works with Tasmota.
GNU General Public License v3.0
856 stars 187 forks source link

feat: calculate yAxisTicks based on given values #1142

Closed theknut closed 5 months ago

theknut commented 5 months ago

IMHO the yAxisTicks parameter for chartPage is a little bit hard to understand, given the required formatting. Besides that, in the example the yAxisTicks for the office temperature are from -25° to +25° C which makes no sense, at least for me. But there is really no need to provide them at all because we can caluclate the yAxisTicks based on the provided values. In this pull request there is an added algorithm which calculates the ticks if no yAxisTicks was provided for the page. This makes configuring the chartPage a little bit easier and more responsive.

Example debug logging:

Calculated yAxisTicks for 0_userdata.0....Temperature (Min: 186, Max: 214, Tick: 10): 176,186,196,206,216
Calculated yAxisTicks for 0_userdata.0....Humidity (Min: 650, Max: 729, Tick: 16): 634,650,666,682,698,714,730
Calculated yAxisTicks for 0_userdata.0....Speedtest.Download (Min: 137, Max: 581, Tick: 89): 48,137,226,315,404,493,582

Notice how the amount of calculated ticks changes with the given range of values to display.

image

theknut commented 5 months ago

Additionally the documentation needs to be updated accordingly. I have an updated script for writing the signal values using InfluxDB. I can update the documentation with the same PR, if you like.

Armilar commented 5 months ago

Works very well. For the documentation in the Wiki, all that needs to be noted is that the yAxisTicks parameter is not required in the PageItem and is calculated automatically in this case.

image

theknut commented 5 months ago

I'll do that together with the next upcomming PR.