Sensor graphs question/suggestion

Just updated to version 1.5 and I see that the sensor graphs are new (or changed configuration at least). The problem I now see is that the default zoom level is too small - just around the latest datapoint. We use sensor to log operation hours of our equipment (to keep track of oil-changes as other maintenance) so the interesting is the trend, possibly 3 months.
If it would be possible to set a default for graph interval that would be very nice :slight_smile:

Thanks,
/Mattias

1 Like

Hi @mattias - welcome to the farmOS forum!

You’re correct: a change was made in 1.5 to the way that the graphs work. We had graphs in 1.4 as well, but they always displayed the “last 100 data points”. This worked well for both new sensors and old sensors, but didn’t allow you to view older data, or different ranges of data.

@paul121 added some new filter capabilities, which now default the graphs to showing the “last week” of data, which will look at the timestamp of the last data point received, and then load all data within a week previous to that. After the page is loaded you can change the filters to tweak the range.

Right now the “last week” range is hard-coded, but I could see the potential for making that configurable on a per-sensor basis. In other words, when you create a new sensor, perhaps you could alter the default range to be “last 90 days” like you describe.

In the meantime, are you able to get the information you need by modifying the default filters after the graphs load?

Ah shoot, that makes sense. Sorry for the change @mattias!

Adding a default range to the sensor settings is a great idea though @mstenta ! This could actually be used to pre-populate the date range in the Sensors Field Module I’m working on, too. So maybe I can try and add that here soon. What do you think, simply saving an integer number of days in the sensor settings? Seems like that would provide enough granularity for most use cases.

1 Like

@mstenta
Yea, it took me some time to understand that “Filter” meant filters for the graph. Have been so used to Filters in the Logs… Took me some time understand why clicking “-” in the graph didn’t do anything (it zooms out 0.01 seconds…)

@paul121
Always though when your user throws you curve balls, right? Been there, done that and got the T-shirt :slight_smile: For my use-case I’d prefer a year, but that’s just me. Maybe show at least three points and set the zoom to something better than 0.01 seconds?
Having a way to set the label of the y-axis and graph subject would also be nice :wink:

Attaching two of our graphs for inspiration. First one is odometer for one of our tractors and second is the hour of operation for the wood chipper.

2 Likes

1 Like

For my use-case I’d prefer a year, but that’s just me.

You could still enter 365 days! Going for maximum flexibility! :smiley:

Maybe show at least three points

Yeah that’s a good idea too. Show the last week of data OR 100 data points. Which ever has more.

and set the zoom to something better than 0.01 seconds?

Ahh yes I think I see what you’re saying. The zoom is handled by the Plotly library and seems to be relative to how much data is on the graph. With one data point, the zoom is in fact .01 seconds, but with more data points it becomes more sensible. This happens because Plotly doesn’t know about the other sensor data (it wasn’t loaded from the database).

Perhaps we should instead load lots of data from the DB (maybe 500 points max) and have Plotly display that in a “best fit” method. 500 points might fill up a single week, or in your case Plotly could choose to only display the ~20 points in the most recent year. I’m curious if it has “autoscaling” capabilities… will do some looking and get back with what I find!

1 Like

How does Plotly load the data? Do you need to shove all the data in at load-time or could it poll the server for more data as needed? Thinking performance hits here…
We monitor things like weather data, PV production etc in emoncms and the graphing library there could sometimes be overwhelmed with long periods or many data streams.

1 Like

Just some food for thought from emoncms…

2 Likes