[feature] Add smoothLimit for Line

This commit is contained in:
monitor1394
2022-10-10 07:07:57 +08:00
parent 5ed6ee1d2a
commit 0662f62cd1
4 changed files with 17 additions and 1 deletions

View File

@@ -59,6 +59,7 @@
## master ## master
* (2022.09.10) 增加`Line``SmoothLimit`可控制平滑曲线不同效果
* (2022.09.05) 修复`Serie`隐藏时`Tooltip`还显示信息的问题 * (2022.09.05) 修复`Serie`隐藏时`Tooltip`还显示信息的问题
* (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常 * (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常

View File

@@ -18,6 +18,10 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex"); PropertyField("m_YAxisIndex");
} }
PropertyField("m_LineType"); PropertyField("m_LineType");
if (serie.lineType == LineType.Smooth)
{
PropertyField("m_SmoothLimit");
}
//PropertyField("m_Clip"); //PropertyField("m_Clip");
PropertyFiledMore(() => PropertyFiledMore(() =>
{ {

View File

@@ -505,7 +505,7 @@ namespace XCharts.Runtime
if (isY) if (isY)
UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle); UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle);
else 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++) for (int j = 1; j < s_CurvesPosList.Count; j++)
{ {
serie.context.drawPoints.Add(new PointInfo(s_CurvesPosList[j], ignore)); serie.context.drawPoints.Add(new PointInfo(s_CurvesPosList[j], ignore));

View File

@@ -247,6 +247,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_SampleAverage = 0; [SerializeField] private float m_SampleAverage = 0;
[SerializeField] private LineType m_LineType = LineType.Normal; [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 BarType m_BarType = BarType.Normal;
[SerializeField] private bool m_BarPercentStack = false; [SerializeField] private bool m_BarPercentStack = false;
[SerializeField] private float m_BarWidth = 0; [SerializeField] private float m_BarWidth = 0;
@@ -492,6 +493,16 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
} }
/// <summary> /// <summary>
/// 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时两个连续相同数值的数据间的曲线会限制为不超出数据点和数据点是平直的。
/// </summary>
public bool smoothLimit
{
get { return m_SmoothLimit; }
set { if (PropertyUtil.SetStruct(ref m_SmoothLimit, value)) { SetVerticesDirty(); } }
}
/// <summary>
/// the min pixel dist of sample. /// the min pixel dist of sample.
/// |采样的最小像素距离默认为0时不采样。当两个数据点间的水平距离小于改值时开启采样保证两点间的水平距离不小于改值。 /// |采样的最小像素距离默认为0时不采样。当两个数据点间的水平距离小于改值时开启采样保证两点间的水平距离不小于改值。
/// </summary> /// </summary>