-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale temperature chart based on min/max temp data #1013
Conversation
Dynamically adjust gradient setup based on temp data range
I would like to be able to handle negative temperature numbers better, but scaling to the available data is less useful for temperature as you can't easily tell if it is hot or cold. |
I am working on a more configurable EnvironmentMetricsLog view that allows you to select attributes to show in chart and table. This kind of requires using the auto-scaling Swift Charts as putting multiple metrics on one chart requires it to scale appropriately for all selected data series. Its not quite ready for pull, but I'll mention it here in case you'd like to take a look at where it stands: https://github.com/jake-b/Meshtastic-Apple/tree/configurable_columns Making things dynamic adds a bit of complexity and some mildly nimble use of the type system. Still working on a few details. |
Nice. I'll take a look. In the meantime, if the dynamic gradient stop code is helpful feel free to grab it. I'm also going to push some other changes that I was playing with for reference. |
e9a7212
to
bc93256
Compare
Minor fixes
y: .value("Temperature", dataPoint.temperature.localeTemperature()), | ||
stacking: .unstacked | ||
yStart: .value("Temperature", dataPoint.temperature.localeTemperature()), | ||
yEnd: .value("Minimum Temperature", chartLowTemp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will set the end for the area chart to the minimum temperature so that the area is filled in from the temp to the bottom of the chart. Otherwise the end is 0, meaning the area will be drawn from the y point to 0. For negative temp values, the area will be filled in below 0.
@@ -52,12 +58,9 @@ struct EnvironmentMetricsLog: View { | |||
x: .value("Time", dataPoint.time!), | |||
y: .value("Temperature", dataPoint.temperature.localeTemperature()) | |||
) | |||
.interpolationMethod(.cardinal) | |||
.interpolationMethod(.catmullRom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to consider trying .catmullRom. When there are large jumps in time and value in these charts, the .cardinal interpolation can create some odd curves. .catmullRom isn't perfect, but it handles some of this a bit better.
} | ||
} | ||
|
||
// Set up gradient stops relative to the scale of the temperature chart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently implemented for mapping temperature to gradient stops. But this could be used for other gradient mapping by modifying the stopTargets array elements.
Closing in favor of #1016 |
What changed?
This change scales the temperature chart to the min/max temperature data. Also, the gradient is dynamically adjusted based on the min/max temperatures.
Why did it change?
The temperature chart is more readable when scaled.
How is this tested?
Tested charts with live data from multiple nodes.
Also tested gradient adjustment against canned data.
Screenshots/Videos (when applicable)
Checklist