From 9d3d8543a545803a655819e2283500fac4b6a900 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 4 Aug 2023 08:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`LabelLine`=E7=9A=84`lineEndX?= =?UTF-8?q?`=E5=8F=AF=E8=AE=BE=E7=BD=AE=E5=BC=95=E5=AF=BC=E7=BA=BF?= =?UTF-8?q?=E5=9B=BA=E5=AE=9AX=E4=BD=8D=E7=BD=AE=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 4 ++++ Documentation~/en/configuration.md | 1 + Documentation~/zh/api.md | 4 ++++ Documentation~/zh/changelog.md | 2 ++ Documentation~/zh/configuration.md | 1 + Editor/ChildComponents/LabelLineDrawer.cs | 1 + Runtime/Component/Label/LabelLine.cs | 15 +++++++++++++-- Runtime/Serie/Ring/RingHandler.cs | 1 - 8 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 991d42fa..a9fc4f3c 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -1047,6 +1047,8 @@ the data of serie event. |public method|since|description| |--|--|--| +|AfterUpdate()||public virtual void AfterUpdate() { }| +|BeforeUpdate()||public virtual void BeforeUpdate() { }| |CheckComponent()||public virtual void CheckComponent(StringBuilder sb) { }| |DrawBase()||public virtual void DrawBase(VertexHelper vh) { }| |DrawSerie()||public virtual void DrawSerie(VertexHelper vh) { }| @@ -1082,6 +1084,8 @@ the data of serie event. |public method|since|description| |--|--|--| +|AfterUpdate()||public override void AfterUpdate()| +|BeforeUpdate()||public override void BeforeUpdate()| |DrawLabelLineSymbol()||public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor)| |ForceUpdateSerieContext()||public override void ForceUpdateSerieContext()| |GetPointerItemDataDimension()||public override int GetPointerItemDataDimension()| diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index d1643fca..24b6b77f 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -1165,6 +1165,7 @@ The interface for serie data component. |lineGap|1.0f||the gap of container and guild line. |lineLength1|25f||The length of the first segment of visual guide line. |lineLength2|15f||The length of the second segment of visual guide line. +|lineEndX|0f|v3.8.0|The fixed x position of the end point of visual guide line. |startSymbol|||The symbol of the start point of labelline. [SymbolStyle](#symbolstyle)| |endSymbol|||The symbol of the end point of labelline. [SymbolStyle](#symbolstyle)| diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 50379e17..6a22b642 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -1047,6 +1047,8 @@ serie事件的数据。 |public method|since|description| |--|--|--| +|AfterUpdate()||public virtual void AfterUpdate() { }| +|BeforeUpdate()||public virtual void BeforeUpdate() { }| |CheckComponent()||public virtual void CheckComponent(StringBuilder sb) { }| |DrawBase()||public virtual void DrawBase(VertexHelper vh) { }| |DrawSerie()||public virtual void DrawSerie(VertexHelper vh) { }| @@ -1082,6 +1084,8 @@ serie事件的数据。 |public method|since|description| |--|--|--| +|AfterUpdate()||public override void AfterUpdate()| +|BeforeUpdate()||public override void BeforeUpdate()| |DrawLabelLineSymbol()||public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor)| |ForceUpdateSerieContext()||public override void ForceUpdateSerieContext()| |GetPointerItemDataDimension()||public override int GetPointerItemDataDimension()| diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 75a17591..572dda2f 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -76,6 +76,8 @@ slug: /changelog 日志详情: +* (2023.08.04) 增加`LabelLine`的`lineEndX`可设置引导线固定X位置的支持 +* (2023.08.04) 增加`Ring`的`avoidLabelOverlap`避免文本堆叠的支持 (#247) * (2023.08.03) 完善`Chart`的`onSerieEnter`,`onSerieExit`和`onSerieClick`回调 * (2023.08.02) 修复`BarChart`的`onSerieEnter`和`onSerieExit`回调无效的问题 * (2023.08.02) 增加`Symbol`的`Plus`加号和`Minus`减号的支持 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 0c30fea7..6be74eda 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -1165,6 +1165,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |lineGap|1.0f||视觉引导线和容器的间距。 |lineLength1|25f||视觉引导线第一段的长度。 |lineLength2|15f||视觉引导线第二段的长度。 +|lineEndX|0f|v3.8.0|视觉引导线结束点的固定x位置。当不为0时,会代替lineLength2设定引导线的x位置。 |startSymbol|||起始点的图形标记。 [SymbolStyle](#symbolstyle)| |endSymbol|||结束点的图形标记。 [SymbolStyle](#symbolstyle)| diff --git a/Editor/ChildComponents/LabelLineDrawer.cs b/Editor/ChildComponents/LabelLineDrawer.cs index dcd2d6c3..e26fd567 100644 --- a/Editor/ChildComponents/LabelLineDrawer.cs +++ b/Editor/ChildComponents/LabelLineDrawer.cs @@ -21,6 +21,7 @@ namespace XCharts.Editor PropertyField(prop, "m_LineGap"); PropertyField(prop, "m_LineLength1"); PropertyField(prop, "m_LineLength2"); + PropertyField(prop, "m_LineEndX"); PropertyField(prop, "m_StartSymbol"); PropertyField(prop, "m_EndSymbol"); --EditorGUI.indentLevel; diff --git a/Runtime/Component/Label/LabelLine.cs b/Runtime/Component/Label/LabelLine.cs index 02363a05..e959a385 100644 --- a/Runtime/Component/Label/LabelLine.cs +++ b/Runtime/Component/Label/LabelLine.cs @@ -36,6 +36,7 @@ namespace XCharts.Runtime [SerializeField] private float m_LineGap = 1.0f; [SerializeField] private float m_LineLength1 = 25f; [SerializeField] private float m_LineLength2 = 15f; + [SerializeField][Since("v3.8.0")] private float m_LineEndX = 0f; [SerializeField] private SymbolStyle m_StartSymbol = new SymbolStyle() { show = false, type = SymbolType.Circle, size = 3 }; [SerializeField] private SymbolStyle m_EndSymbol = new SymbolStyle() { show = false, type = SymbolType.Circle, size = 3 }; @@ -49,6 +50,7 @@ namespace XCharts.Runtime m_LineGap = 1.0f; m_LineLength1 = 25f; m_LineLength2 = 15f; + m_LineEndX = 0; } /// @@ -124,6 +126,15 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); } } /// + /// The fixed x position of the end point of visual guide line. + /// |视觉引导线结束点的固定x位置。当不为0时,会代替lineLength2设定引导线的x位置。 + /// + public float lineEndX + { + get { return m_LineEndX; } + set { if (PropertyUtil.SetStruct(ref m_LineEndX, value)) SetVerticesDirty(); } + } + /// /// The symbol of the start point of labelline. /// |起始点的图形标记。 /// @@ -144,12 +155,12 @@ namespace XCharts.Runtime public Vector3 GetStartSymbolOffset() { - return m_StartSymbol != null && m_StartSymbol.show? m_StartSymbol.offset3 : Vector3.zero; + return m_StartSymbol != null && m_StartSymbol.show ? m_StartSymbol.offset3 : Vector3.zero; } public Vector3 GetEndSymbolOffset() { - return m_EndSymbol != null && m_EndSymbol.show? m_EndSymbol.offset3 : Vector3.zero; + return m_EndSymbol != null && m_EndSymbol.show ? m_EndSymbol.offset3 : Vector3.zero; } } } \ No newline at end of file diff --git a/Runtime/Serie/Ring/RingHandler.cs b/Runtime/Serie/Ring/RingHandler.cs index d9007afb..4d612f84 100644 --- a/Runtime/Serie/Ring/RingHandler.cs +++ b/Runtime/Serie/Ring/RingHandler.cs @@ -445,7 +445,6 @@ namespace XCharts.Runtime ChartHelper.GetHighlightColor(defaltColor, 0.9f) : labelLine.lineColor; var isRight = !serie.clockwise; - var dire = isRight ? Vector3.right : Vector3.left; var rad = Mathf.Deg2Rad * (isRight ? labelLine.lineAngle : 180 - labelLine.lineAngle); var lineLength1 = ChartHelper.GetActualValue(labelLine.lineLength1, serie.context.outsideRadius); var pos1 = serieData.context.labelLinePosition;