From 604c59723f9e1720451ebcdfb6e403765a084a12 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Sat, 14 Sep 2019 12:07:26 +0200 Subject: [PATCH] (1) Production Tracing tab removed from MoreWMResultsDlg, (2) WMChart: testRslt.TestTime used instead of mtr.TestTime, AxisX Minimum and Maximum. --- Results/Forms/MoreWMResultsDlg.cs | 2 +- Results/Output/WMChart.cs | 43 ++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Results/Forms/MoreWMResultsDlg.cs b/Results/Forms/MoreWMResultsDlg.cs index dd6e36cc9..91cb5dfbc 100644 --- a/Results/Forms/MoreWMResultsDlg.cs +++ b/Results/Forms/MoreWMResultsDlg.cs @@ -26,7 +26,7 @@ namespace Results.Forms if (refRecords == null) { tabControl1.SelectTab(1); - tabControl1.TabPages[2].Hide(); + tabControl1.TabPages.RemoveAt(2); } else { diff --git a/Results/Output/WMChart.cs b/Results/Output/WMChart.cs index 1c84a5e21..6d5499768 100644 --- a/Results/Output/WMChart.cs +++ b/Results/Output/WMChart.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using System.Text; using System.Windows.Forms.DataVisualization.Charting; using Config.Entities; using Results.Entities; @@ -22,9 +21,9 @@ namespace Results.Output IList unsortedPoints = new List(); foreach (var mtr in wm.MeterTestRslts) { - if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0)) + if (mtr.IsPilotRslt() && mtr.TestRslt.TestData.Evaluate && (mtr.TestRslt.TestTime > 0) && (mtr.TestRslt.PulsesMaster > 0)) { - double flow = Config.Units.ConvertTo(flowUnit, mtr.TestRslt.VolumeCTV / mtr.TestTime * 3.6 * mtr.PulsesMaster / mtr.TestRslt.PulsesMaster); + double flow = Config.Units.ConvertTo(flowUnit, 3.6 * mtr.TestRslt.VolumeCTV / mtr.TestRslt.TestTime); if (flow > 0) { unsortedPoints.Add(new PointF((float)flow, (float)mtr.Error)); @@ -47,7 +46,7 @@ namespace Results.Output chArea.AxisX.Title = Strings.Flow; chArea.AxisX.IsLogarithmic = true; chArea.AxisX.LogarithmBase = 10; - chArea.AxisX.IsLabelAutoFit = false; + chArea.AxisX.IsLabelAutoFit = true; List xs = new List() { 0.0001, 0.0002, 0.0005, 0.001, 0.002, 0.005, @@ -59,19 +58,43 @@ namespace Results.Output 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, - 1000000, 2000000, 5000000 }; + 1000000, 2000000, 5000000, + 10000000 }; double spacer = 0.8; double from = Config.Units.ConvertTo(flowUnit, wm.WaterMeterData.Q1_Qmin); double to = Config.Units.ConvertTo(flowUnit, isQ4 ? wm.WaterMeterData.Q4_Qmax : wm.WaterMeterData.Q3_Qn); - for (int i = 1; i < xs.Count - 1; i++) + bool inRange = false; + for (int i = 0; i < xs.Count - 3; i += 3) { - if ((xs[i + 1] > from) && (xs[i - 1] < to)) + if (xs[i] <= from && from < xs[i + 3]) { + chArea.AxisX.Minimum = xs[i]; + inRange = true; + } + + if (inRange) + { + for (int j = i; j < i + 3; j++) + { + CustomLabel cl = new CustomLabel(); + cl.Text = string.Format("{0} {1}", xs[j], flowUnit.ToDescription()); + cl.FromPosition = Math.Log10(xs[j] * spacer); + cl.ToPosition = Math.Log10(xs[j] / spacer); + chArea.AxisX.CustomLabels.Add(cl); + } + } + + if (xs[i] < to && to <= xs[i + 3]) + { + chArea.AxisX.Maximum = xs[i + 3]; + CustomLabel cl = new CustomLabel(); - cl.Text = string.Format("{0} {1}", xs[i], flowUnit.ToDescription()); - cl.FromPosition = Math.Log10(xs[i] * spacer); - cl.ToPosition = Math.Log10(xs[i] / spacer); + cl.Text = string.Format("{0} {1}", xs[i + 3], flowUnit.ToDescription()); + cl.FromPosition = Math.Log10(xs[i + 3] * spacer); + cl.ToPosition = Math.Log10(xs[i + 3] / spacer); chArea.AxisX.CustomLabels.Add(cl); + + break; } }