Commit 3ece0d23 authored by 潘栩锋's avatar 潘栩锋 🚴

修复 扫描图,即时图,纵向图,当均值<5时,不能以%显示。

parent 60b9f44a
......@@ -21,6 +21,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
const int MARKNO_TEXTUP = 1;
const int MARKNO_TARGET_DELAY = 2;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
#region 图表控制
public double YMax { get; set; } = double.NaN;
public double YMin { get; set; } = double.NaN;
......@@ -115,10 +124,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = "";
if (graphparam.IsPercent)
{
double target = Target;
if (target > 0)
if (graphparam.IsPercent && target > MIN_PERCENT_TARGET)
{
if (y == target)
{
......@@ -141,11 +148,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
text = y.ToString("F1");
}
}
else
{
text = y.ToString("F1");
}
return $"{text,6}";
};
......@@ -315,6 +317,10 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
double tolerance = this.profileParam.TolerancePercent * target;
//确保没有负数,Y轴显示范围正确
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
Target = target;
ToleranceYMax = target + tolerance;
ToleranceYMin = target - tolerance;
......@@ -342,7 +348,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
PollModule.Current.Poll_JustOnce(() =>
{
if (graphparam.IsPercent && (Average > 0))
if (graphparam.IsPercent && (Average > MIN_PERCENT_TARGET))
{
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
......
......@@ -22,6 +22,15 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
const int MARKNO_TEXTUP = 1;
const int MARKNO_TARGET_DELAY = 2;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
#region 图表控制
public double YMax { get; set; } = double.NaN;
public double YMin { get; set; } = double.NaN;
......@@ -103,10 +112,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
//只显示 Target,ToleranceYMax,ToleranceYMin,Tolerance2YMax,Tolerance2YMin
string text = "";
if (graphparam.IsPercent)
{
double target = Target;
if (target > 0)
if (graphparam.IsPercent && target > MIN_PERCENT_TARGET)
{
if (y == target)
{
......@@ -129,13 +136,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
text = y.ToString("F1");
}
}
else
{
text = y.ToString("F1");
}
return $"{text,6}";
};
XFormatter = (x) =>
{
//全部+1
......@@ -403,7 +406,8 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
double tolerance = this.profileParam.TolerancePercent * target;
if (tolerance < MIN_TOLERANCE)
tolerance = MIN_TOLERANCE;
TolerancePercent = profileParam.TolerancePercent;
Target = target;
......@@ -433,7 +437,7 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
}
protected void UpdateMaxMinText()
{
if (graphparam.IsPercent && (Average > 0))
if (graphparam.IsPercent && (Average > MIN_PERCENT_TARGET))
{
MaxText = $"+{((Max - Average) / Average) * 100.0:F1}%";
MinText = $"-{((Average - Min) / Average) * 100.0:F1}%";
......
......@@ -20,6 +20,14 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
/// </summary>
const int AutoKeepTotalSec = 60;
const int Len = 100;
/// <summary>
/// Y轴%显示,最小的中值
/// </summary>
const int MIN_PERCENT_TARGET = 5;
/// <summary>
/// Y轴最小公差范围
/// </summary>
const int MIN_TOLERANCE = 1;
public event PropertyChangedEventHandler PropertyChanged;
......@@ -127,37 +135,40 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
return "";
};
MapperPositive = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => 2 * value.Sigma / value.Value)
.Fill((value) =>
{
double percent = 2 * value.Sigma / value.Value;
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
.X((value, index) => index)
.Y(value => ToSigma2Percent(value))
.Fill((value) => ToBrush(value));
MapperNegative = Mappers.Xy<TrendValue>()
.X((value, index) => index)
.Y(value => -ToSigma2Percent(value))
.Fill((value) => ToBrush(value));
MapperValue = Mappers.Xy<TrendValue>()
.X((value, index) => index)
.Y(value => value.Value)
.Stroke((value) =>
{
return AreaColors[2];
}
else if ((percent > ToleranceYMax) || (percent < -ToleranceYMax))
if (value.ProfileID % 2 == 0)
{
return AreaColors[1];
return null;
}
else
{
return AreaColors[0];
return System.Windows.Media.Brushes.DarkBlue;
}
});
MapperNegative = Mappers.Xy<TrendValue>()
.X((value, index) =>
#endregion
}
Brush ToBrush(TrendValue value)
{
return index;
})
.Y(value => -2 * value.Sigma / value.Value)
.Fill((value) =>
double percent = ToSigma2Percent(value);
if (double.IsNaN(percent))
{
double percent = 2 * value.Sigma / value.Value;
return AreaColors[0];
}
if ((percent > Tolerance2YMax) || (percent < -Tolerance2YMax))
{
return AreaColors[2];
......@@ -170,27 +181,6 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
{
return AreaColors[0];
}
});
MapperValue = Mappers.Xy<TrendValue>()
.X((value, index) =>
{
return index;
})
.Y(value => value.Value)
.Stroke((value) =>
{
if (value.ProfileID % 2 == 0)
{
return null;
}
else
{
return System.Windows.Media.Brushes.DarkBlue;
}
});
#endregion
}
public void Init(
TrendGraphItemParam graphparam,
......@@ -275,7 +265,9 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
void UpdateY()
{
double tolerance = this.profileParam.TolerancePercent;
if (tolerance < MIN_TOLERANCE) {
tolerance = MIN_TOLERANCE;
}
ToleranceYMax = tolerance;
ToleranceYMin = -tolerance;
Tolerance2YMax = tolerance * 2;
......@@ -307,9 +299,25 @@ namespace FLY.Thick.FilmCasting.UI.UiModule
}
}
}
double ToSigma2Percent(TrendValue v)
{
if (double.IsNaN(v.Value))
{
return double.NaN;
}
else if (v.Value < MIN_PERCENT_TARGET)
{
return double.NaN;
}
else
{
return 2 * v.Sigma / v.Value;
}
}
void UpdateAverage()
{
var sigma2s = this.Values.Select(v => 2 * v.Sigma / v.Value);
var sigma2s = this.Values.Select(v => ToSigma2Percent(v));
var list = from v in sigma2s where !double.IsNaN(v) select v;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment