]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Auto-scale sensor monitoring graph (#29559)
authorPartmedia <kevinz5000@gmail.com>
Sun, 30 Jun 2024 13:48:20 +0000 (05:48 -0800)
committerGitHub <noreply@github.com>
Sun, 30 Jun 2024 13:48:20 +0000 (09:48 -0400)
Content.Client/SensorMonitoring/SensorMonitoringWindow.xaml.cs

index 9fc132c74792592bb723402cff1020139431d011..307307c687a2334492e37f7cb1e4f19514cf7a87 100644 (file)
@@ -129,14 +129,7 @@ public sealed partial class SensorMonitoringWindow : FancyWindow, IComputerWindo
 
             foreach (var stream in sensor.Streams.Values)
             {
-                var maxValue = stream.Unit switch
-                {
-                    SensorUnit.PressureKpa => 5000, // 5 MPa
-                    SensorUnit.Ratio => 1,
-                    SensorUnit.PowerW => 1_000_000, // 1 MW
-                    SensorUnit.EnergyJ => 2_000_000, // 2 MJ
-                    _ => 1000
-                };
+                var maxValue = stream.Samples.Max(x => x.Value);
 
                 // TODO: Better way to do this?
                 var lastSample = stream.Samples.Last();
@@ -151,7 +144,7 @@ public sealed partial class SensorMonitoringWindow : FancyWindow, IComputerWindo
                     }
                 });
 
-                Asdf.AddChild(new GraphView(stream.Samples, startTime, curTime, maxValue) { MinHeight = 150 });
+                Asdf.AddChild(new GraphView(stream.Samples, startTime, curTime, maxValue * 1.1f) { MinHeight = 150 });
                 Asdf.AddChild(new PanelContainer { StyleClasses = { StyleBase.ClassLowDivider } });
             }
         }