From e3e01587abe682abde4d19c625598a775977806a Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 2 Aug 2023 07:23:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Symbol`=E7=9A=84`Plus`?= =?UTF-8?q?=E5=8A=A0=E5=8F=B7=E5=92=8C`Minus`=E5=87=8F=E5=8F=B7=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 6 ++++ Documentation~/en/configuration.md | 4 +-- Documentation~/zh/api.md | 6 ++++ Documentation~/zh/changelog.md | 1 + Documentation~/zh/configuration.md | 4 +-- Runtime/Component/Child/SymbolStyle.cs | 10 ++++++- Runtime/Internal/Utilities/ChartDrawer.cs | 14 +++++++++ Runtime/XUGL/UGL.cs | 35 +++++++++++++++++++++++ 8 files changed, 75 insertions(+), 5 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 7c5245db..991d42fa 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -668,6 +668,7 @@ slug: /api |SetColor()||public void SetColor(ref bool needInteract, Color32 color)| |SetColor()||public void SetColor(ref bool needInteract, Color32 color, Color32 toColor)| |SetPosition()||public void SetPosition(ref bool needInteract, Vector3 pos)| +|SetValue()||public void SetValue(float value)| |SetValue()||public void SetValue(ref bool needInteract, float value)| |SetValue()||public void SetValue(ref bool needInteract, float value, bool highlight, float rate = 1.3f)| |SetValueAndColor()||public void SetValueAndColor(ref bool needInteract, float value, Color32 color)| @@ -1051,6 +1052,7 @@ the data of serie event. |DrawSerie()||public virtual void DrawSerie(VertexHelper vh) { }| |DrawTop()||public virtual void DrawTop(VertexHelper vh) { }| |DrawUpper()||public virtual void DrawUpper(VertexHelper vh) { }| +|ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }| |InitComponent()||public virtual void InitComponent() { }| |OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }| |OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }| @@ -1081,6 +1083,7 @@ the data of serie event. |public method|since|description| |--|--|--| |DrawLabelLineSymbol()||public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor)| +|ForceUpdateSerieContext()||public override void ForceUpdateSerieContext()| |GetPointerItemDataDimension()||public override int GetPointerItemDataDimension()| |GetPointerItemDataIndex()||public override int GetPointerItemDataIndex()| |GetSerieDataAutoColor()||public virtual Color GetSerieDataAutoColor(SerieData serieData)| @@ -1297,10 +1300,13 @@ UGUI Graphics Library. |--|--|--| |DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color)
Draw a diamond. 画菱形(钻石形状) | |DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color, Color32 toColor)
Draw a diamond. 画菱形(钻石形状) | +|DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float xRadius, float yRadius, Color32 color, Color32 toColor)| |DrawEllipse()||public static void DrawEllipse(VertexHelper vh, Vector3 center, float w, float h, Color32 color, float smoothness = 1)| |DrawLine()||public static void DrawLine(VertexHelper vh, List<Vector3> points, float width, Color32 color, bool smooth, bool closepath = false)| |DrawLine()||public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color)
Draw a line. 画直线 | |DrawLine()||public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color, Color32 toColor)
Draw a line. 画直线 | +|DrawMinus()||public static void DrawMinus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color)
Draw minus sign. | +|DrawPlus()||public static void DrawPlus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color)
Draw plus sign. | |DrawPolygon()||public static void DrawPolygon(VertexHelper vh, List<Vector3> points, Color32 color)
填充任意多边形(目前只支持凸多边形) | |DrawRectangle()||public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color)| |DrawRectangle()||public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color, Color32 toColor)| diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index eba54676..d1643fca 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -1160,7 +1160,7 @@ The interface for serie data component. |show|true||Whether the label line is showed. |lineType|||the type of visual guide line.
`LabelLine.LineType`:
- `BrokenLine`: 折线
- `Curves`: 曲线
- `HorizontalLine`: 水平线
| |lineColor|Color32(0,0,0,0)||the color of visual guild line. -|lineAngle|0||the angle of visual guild line. +|lineAngle|60||the angle of visual guild line. |lineWidth|1.0f||the width of visual guild line. |lineGap|1.0f||the gap of container and guild line. |lineLength1|25f||The length of the first segment of visual guide line. @@ -1979,7 +1979,7 @@ the state style of serie. |field|default|since|comment| |--|--|--|--| |show|true||Whether the symbol is showed. -|type|||the type of symbol.
`SymbolType`:
- `None`: 不显示标记。
- `Custom`: 自定义标记。
- `Circle`: 圆形。
- `EmptyCircle`: 空心圆。
- `Rect`: 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
- `EmptyRect`: 空心正方形。
- `Triangle`: 三角形。
- `EmptyTriangle`: 空心三角形。
- `Diamond`: 菱形。
- `EmptyDiamond`: 空心菱形。
- `Arrow`: 箭头。
- `EmptyArrow`: 空心箭头。
| +|type|||the type of symbol.
`SymbolType`:
- `None`: 不显示标记。
- `Custom`: 自定义标记。
- `Circle`: 圆形。
- `EmptyCircle`: 空心圆。
- `Rect`: 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
- `EmptyRect`: 空心正方形。
- `Triangle`: 三角形。
- `EmptyTriangle`: 空心三角形。
- `Diamond`: 菱形。
- `EmptyDiamond`: 空心菱形。
- `Arrow`: 箭头。
- `EmptyArrow`: 空心箭头。
- `Plus`: 加号。
- `Minus`: 减号。
| |size|0f||the size of symbol. |gap|0||the gap of symbol and line segment. |width|0f||图形的宽。 diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 9fdea84d..50379e17 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -668,6 +668,7 @@ slug: /api |SetColor()||public void SetColor(ref bool needInteract, Color32 color)| |SetColor()||public void SetColor(ref bool needInteract, Color32 color, Color32 toColor)| |SetPosition()||public void SetPosition(ref bool needInteract, Vector3 pos)| +|SetValue()||public void SetValue(float value)| |SetValue()||public void SetValue(ref bool needInteract, float value)| |SetValue()||public void SetValue(ref bool needInteract, float value, bool highlight, float rate = 1.3f)| |SetValueAndColor()||public void SetValueAndColor(ref bool needInteract, float value, Color32 color)| @@ -1051,6 +1052,7 @@ serie事件的数据。 |DrawSerie()||public virtual void DrawSerie(VertexHelper vh) { }| |DrawTop()||public virtual void DrawTop(VertexHelper vh) { }| |DrawUpper()||public virtual void DrawUpper(VertexHelper vh) { }| +|ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }| |InitComponent()||public virtual void InitComponent() { }| |OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }| |OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }| @@ -1081,6 +1083,7 @@ serie事件的数据。 |public method|since|description| |--|--|--| |DrawLabelLineSymbol()||public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor)| +|ForceUpdateSerieContext()||public override void ForceUpdateSerieContext()| |GetPointerItemDataDimension()||public override int GetPointerItemDataDimension()| |GetPointerItemDataIndex()||public override int GetPointerItemDataIndex()| |GetSerieDataAutoColor()||public virtual Color GetSerieDataAutoColor(SerieData serieData)| @@ -1297,10 +1300,13 @@ UGUI 图形库 |--|--|--| |DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color)
Draw a diamond. 画菱形(钻石形状) | |DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float size, Color32 color, Color32 toColor)
Draw a diamond. 画菱形(钻石形状) | +|DrawDiamond()||public static void DrawDiamond(VertexHelper vh, Vector3 center, float xRadius, float yRadius, Color32 color, Color32 toColor)| |DrawEllipse()||public static void DrawEllipse(VertexHelper vh, Vector3 center, float w, float h, Color32 color, float smoothness = 1)| |DrawLine()||public static void DrawLine(VertexHelper vh, List<Vector3> points, float width, Color32 color, bool smooth, bool closepath = false)| |DrawLine()||public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color)
Draw a line. 画直线 | |DrawLine()||public static void DrawLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width, Color32 color, Color32 toColor)
Draw a line. 画直线 | +|DrawMinus()||public static void DrawMinus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color)
绘制减号 | +|DrawPlus()||public static void DrawPlus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color)
绘制加号 | |DrawPolygon()||public static void DrawPolygon(VertexHelper vh, List<Vector3> points, Color32 color)
填充任意多边形(目前只支持凸多边形) | |DrawRectangle()||public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color)| |DrawRectangle()||public static void DrawRectangle(VertexHelper vh, Rect rect, Color32 color, Color32 toColor)| diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 6a0ef0e6..e97d6da7 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -74,6 +74,7 @@ slug: /changelog 日志详情: +* (2023.08.02) 增加`Symbol`的`Plus`加号和`Minus`减号的支持 * (2023.07.31) 增加`Symbol`的`EmptyTriangle`和`EmptyDiamond`的支持,优化`Symbol`表现效果 * (2023.07.31) 优化`Line`的默认配置效果 * (2023.07.27) 增加`Serie`的`minRadius`可设置最小半径 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 9f6ceec9..0c30fea7 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -1160,7 +1160,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |show|true||是否显示视觉引导线。 |lineType|||视觉引导线类型。
`LabelLine.LineType`:
- `BrokenLine`: 折线
- `Curves`: 曲线
- `HorizontalLine`: 水平线
| |lineColor|Color32(0,0,0,0)||视觉引导线颜色。默认和serie一致取自调色板。 -|lineAngle|0||视觉引导线的固定角度。对折线和曲线有效。 +|lineAngle|60||视觉引导线的固定角度。对折线和曲线有效。 |lineWidth|1.0f||视觉引导线的宽度。 |lineGap|1.0f||视觉引导线和容器的间距。 |lineLength1|25f||视觉引导线第一段的长度。 @@ -1979,7 +1979,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 |field|default|since|comment| |--|--|--|--| |show|true||是否显示标记。 -|type|||标记类型。
`SymbolType`:
- `None`: 不显示标记。
- `Custom`: 自定义标记。
- `Circle`: 圆形。
- `EmptyCircle`: 空心圆。
- `Rect`: 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
- `EmptyRect`: 空心正方形。
- `Triangle`: 三角形。
- `EmptyTriangle`: 空心三角形。
- `Diamond`: 菱形。
- `EmptyDiamond`: 空心菱形。
- `Arrow`: 箭头。
- `EmptyArrow`: 空心箭头。
| +|type|||标记类型。
`SymbolType`:
- `None`: 不显示标记。
- `Custom`: 自定义标记。
- `Circle`: 圆形。
- `EmptyCircle`: 空心圆。
- `Rect`: 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
- `EmptyRect`: 空心正方形。
- `Triangle`: 三角形。
- `EmptyTriangle`: 空心三角形。
- `Diamond`: 菱形。
- `EmptyDiamond`: 空心菱形。
- `Arrow`: 箭头。
- `EmptyArrow`: 空心箭头。
- `Plus`: 加号。
- `Minus`: 减号。
| |size|0f||标记的大小。 |gap|0||图形标记和线条的间隙距离。 |width|0f||图形的宽。 diff --git a/Runtime/Component/Child/SymbolStyle.cs b/Runtime/Component/Child/SymbolStyle.cs index 3b8677a5..3e394a78 100644 --- a/Runtime/Component/Child/SymbolStyle.cs +++ b/Runtime/Component/Child/SymbolStyle.cs @@ -57,7 +57,15 @@ namespace XCharts.Runtime /// /// 空心箭头。 /// - EmptyArrow + EmptyArrow, + /// + /// 加号。 + /// + Plus, + /// + /// 减号。 + /// + Minus, } /// diff --git a/Runtime/Internal/Utilities/ChartDrawer.cs b/Runtime/Internal/Utilities/ChartDrawer.cs index c4b6e42b..da6b0871 100644 --- a/Runtime/Internal/Utilities/ChartDrawer.cs +++ b/Runtime/Internal/Utilities/ChartDrawer.cs @@ -136,6 +136,20 @@ namespace XCharts.Runtime arrowOffset, arrowDent, backgroundColor); } break; + case SymbolType.Plus: + if (gap > 0) + { + UGL.DrawPlus(vh, pos, symbolSize + gap, tickness + gap, backgroundColor); + } + UGL.DrawPlus(vh, pos, symbolSize, tickness, color); + break; + case SymbolType.Minus: + if (gap > 0) + { + UGL.DrawMinus(vh, pos, symbolSize + gap, tickness + gap, backgroundColor); + } + UGL.DrawMinus(vh, pos, symbolSize, tickness, color); + break; } } diff --git a/Runtime/XUGL/UGL.cs b/Runtime/XUGL/UGL.cs index 8dd86a63..54e74d41 100644 --- a/Runtime/XUGL/UGL.cs +++ b/Runtime/XUGL/UGL.cs @@ -1971,5 +1971,40 @@ namespace XUGL vh.AddTriangle(cv, cv + i - 1, cv + i); } } + + /// + /// Draw plus sign. + /// |绘制加号 + /// + /// + /// + /// + /// + /// + public static void DrawPlus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color) + { + var xPos1 = new Vector3(center.x - radius, center.y); + var xPos2 = new Vector3(center.x + radius, center.y); + var yPos1 = new Vector3(center.x, center.y - radius); + var yPos2 = new Vector3(center.x, center.y + radius); + UGL.DrawLine(vh, xPos1, xPos2, tickness, color); + UGL.DrawLine(vh, yPos1, yPos2, tickness, color); + } + + /// + /// Draw minus sign. + /// |绘制减号 + /// + /// + /// + /// + /// + /// + public static void DrawMinus(VertexHelper vh, Vector3 center, float radius, float tickness, Color32 color) + { + var xPos1 = new Vector3(center.x - radius, center.y); + var xPos2 = new Vector3(center.x + radius, center.y); + UGL.DrawLine(vh, xPos1, xPos2, tickness, color); + } } } \ No newline at end of file