diff --git a/SunnyUI/Charts/UILineChart.cs b/SunnyUI/Charts/UILineChart.cs index 48f78969..085ae685 100644 --- a/SunnyUI/Charts/UILineChart.cs +++ b/SunnyUI/Charts/UILineChart.cs @@ -38,6 +38,7 @@ * 2022-07-30: V3.2.2 数据显示的日期格式重构调整至数据序列 Series.XAxisDateTimeFormat * 2022-07-30: V3.2.2 坐标轴的小数位数重构调整至坐标轴标签 AxisLabel.DecimalPlaces * 2022-07-30: V3.2.2 坐标轴的日期格式重构调整至坐标轴标签 AxisLabel.DateTimeFormat + * 2022-08-17: V3.2.3 修复数据全为Nan时绘制出错 ******************************************************************************/ using System; diff --git a/SunnyUI/Charts/UILineChartOption.cs b/SunnyUI/Charts/UILineChartOption.cs index 6b52bd10..3aecb99a 100644 --- a/SunnyUI/Charts/UILineChartOption.cs +++ b/SunnyUI/Charts/UILineChartOption.cs @@ -234,6 +234,12 @@ namespace Sunny.UI } } } + + if (min > max) + { + min = 0; + max = 1; + } } } @@ -276,6 +282,12 @@ namespace Sunny.UI } } } + + if (min > max) + { + min = 0; + max = 1; + } } } } diff --git a/SunnyUI/Common/UGraphics.cs b/SunnyUI/Common/UGraphics.cs index e4f518c1..3892af93 100644 --- a/SunnyUI/Common/UGraphics.cs +++ b/SunnyUI/Common/UGraphics.cs @@ -297,6 +297,8 @@ namespace Sunny.UI /// 笔宽 public static void DrawLine(this Graphics g, Color color, float x1, float y1, float x2, float y2, bool smooth = false, float penWidth = 1) { + if (y1.IsNanOrInfinity() || y2.IsNanOrInfinity() || x1.IsNanOrInfinity() || x2.IsNanOrInfinity()) return; + using (Pen pen = color.Pen(penWidth)) { g.Smooth(smooth);