diff --git a/CHANGELOG.md b/CHANGELOG.md index 7286021a..09933393 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ ## master +* (2022.09.10) 增加`Line`的`SmoothLimit`可控制平滑曲线不同效果 * (2022.09.05) 修复`Serie`隐藏时`Tooltip`还显示信息的问题 * (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常 diff --git a/Editor/Series/LineEditor.cs b/Editor/Series/LineEditor.cs index 5d6c2342..95b2e67c 100644 --- a/Editor/Series/LineEditor.cs +++ b/Editor/Series/LineEditor.cs @@ -18,6 +18,10 @@ namespace XCharts.Editor PropertyField("m_YAxisIndex"); } PropertyField("m_LineType"); + if (serie.lineType == LineType.Smooth) + { + PropertyField("m_SmoothLimit"); + } //PropertyField("m_Clip"); PropertyFiledMore(() => { diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs index 59ef4ece..2998d5a5 100644 --- a/Runtime/Serie/Line/LineHelper.cs +++ b/Runtime/Serie/Line/LineHelper.cs @@ -505,7 +505,7 @@ namespace XCharts.Runtime if (isY) UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle); else - UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, true); + UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, serie.smoothLimit); for (int j = 1; j < s_CurvesPosList.Count; j++) { serie.context.drawPoints.Add(new PointInfo(s_CurvesPosList[j], ignore)); diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index c5e193ad..d1ca38c6 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -247,6 +247,7 @@ namespace XCharts.Runtime [SerializeField] private float m_SampleAverage = 0; [SerializeField] private LineType m_LineType = LineType.Normal; + [SerializeField][Since("v3.3.1")] private bool m_SmoothLimit = true; [SerializeField] private BarType m_BarType = BarType.Normal; [SerializeField] private bool m_BarPercentStack = false; [SerializeField] private float m_BarWidth = 0; @@ -492,6 +493,16 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); } } /// + /// Whether to restrict the curve. When true, the curve between two continuous data of the same value + /// is restricted to not exceed the data point, and is flat to the data point. + /// |是否限制曲线。当为true时,两个连续相同数值的数据间的曲线会限制为不超出数据点,和数据点是平直的。 + /// + public bool smoothLimit + { + get { return m_SmoothLimit; } + set { if (PropertyUtil.SetStruct(ref m_SmoothLimit, value)) { SetVerticesDirty(); } } + } + /// /// the min pixel dist of sample. /// |采样的最小像素距离,默认为0时不采样。当两个数据点间的水平距离小于改值时,开启采样,保证两点间的水平距离不小于改值。 ///