From 7eddebd6608339141009252446a924d1303c1559 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 4 Dec 2024 08:19:08 +0800 Subject: [PATCH 01/17] =?UTF-8?q?=E5=88=A0=E9=99=A4`TextStyle`=E7=9A=84?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E9=85=8D=E7=BD=AE=E9=A1=B9`tmpAlignment`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/ChildComponents/TextStyleDrawer.cs | 5 ++--- Runtime/Component/Child/TextStyle.cs | 14 -------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/Editor/ChildComponents/TextStyleDrawer.cs b/Editor/ChildComponents/TextStyleDrawer.cs index 70f44b6f..d2239723 100644 --- a/Editor/ChildComponents/TextStyleDrawer.cs +++ b/Editor/ChildComponents/TextStyleDrawer.cs @@ -27,14 +27,13 @@ namespace XCharts.Editor PropertyField(prop, "m_Color"); PropertyField(prop, "m_FontSize"); PropertyField(prop, "m_LineSpacing"); + PropertyField(prop, "m_Alignment"); + PropertyField(prop, "m_AutoAlign"); #if dUI_TextMeshPro PropertyField(prop, "m_TMPFontStyle"); PropertyField(prop, "m_TMPSpriteAsset"); - PropertyField(prop, "m_TMPAlignment"); #else PropertyField(prop, "m_FontStyle"); - PropertyField(prop, "m_Alignment"); - PropertyField(prop, "m_AutoAlign"); PropertyField(prop, "m_AutoWrap"); #endif --EditorGUI.indentLevel; diff --git a/Runtime/Component/Child/TextStyle.cs b/Runtime/Component/Child/TextStyle.cs index 36c0489e..1f2c55ea 100644 --- a/Runtime/Component/Child/TextStyle.cs +++ b/Runtime/Component/Child/TextStyle.cs @@ -27,7 +27,6 @@ namespace XCharts.Runtime #if dUI_TextMeshPro [SerializeField] private TMP_FontAsset m_TMPFont; [SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal; - [SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left; [SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset; #endif public bool show @@ -147,15 +146,6 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); } } /// - /// the text alignment of TextMeshPro. - /// ||TextMeshPro字体对齐方式。 - /// - public TextAlignmentOptions tmpAlignment - { - get { return m_TMPAlignment; } - set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); } - } - /// /// the sprite asset of TextMeshPro. /// ||TextMeshPro的Sprite Asset。 /// @@ -214,11 +204,7 @@ namespace XCharts.Runtime public void UpdateAlignmentByLocation(Location location) { -#if dUI_TextMeshPro - m_TMPAlignment = location.runtimeTMPTextAlignment; -#else m_Alignment = location.runtimeTextAlignment; -#endif } public Color GetColor(Color defaultColor) From 333dfb8e376f988cd04ce4520db370cf2134ab83 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 4 Dec 2024 08:19:40 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`UIText`=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 3 +++ Runtime/Internal/Utilities/ChartHelper.cs | 4 ++-- Runtime/Internal/Utilities/UIHelper.cs | 28 +++++++++++------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 8743b88d..93477538 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,9 @@ slug: /changelog ## master +* (2024.11.04) 增加`UIText`扩展组件 +* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment` + ## v3.12.1 版本要点: diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index fb67ad55..4e1d72b7 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -319,7 +319,7 @@ namespace XCharts.Runtime chartText.SetActive(textStyle.show); RectTransform rect = EnsureComponent(txtObj); - rect.localPosition = Vector3.zero; + rect.anchoredPosition3D = Vector3.zero; rect.sizeDelta = sizeDelta; rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; @@ -492,7 +492,7 @@ namespace XCharts.Runtime return label; } - private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax, + public static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax, out Vector2 pivot) { switch (alignment) diff --git a/Runtime/Internal/Utilities/UIHelper.cs b/Runtime/Internal/Utilities/UIHelper.cs index 54f9ff25..592df19c 100644 --- a/Runtime/Internal/Utilities/UIHelper.cs +++ b/Runtime/Internal/Utilities/UIHelper.cs @@ -27,27 +27,27 @@ namespace XCharts.Runtime borderWidth, borderColor); } - internal static void InitBackground(UIComponent table) + internal static void InitBackground(UIComponent component) { - if (table.background.show == false || - (table.background.image == null && ChartHelper.IsClearColor(table.background.imageColor))) + if (component.background.show == false || + (component.background.image == null && ChartHelper.IsClearColor(component.background.imageColor))) { - ChartHelper.DestoryGameObject(table.transform, "Background"); + ChartHelper.DestoryGameObject(component.transform, "Background"); return; } - var sizeDelta = table.background.imageWidth > 0 && table.background.imageHeight > 0 ? - new Vector2(table.background.imageWidth, table.background.imageHeight) : - table.graphSizeDelta; - var backgroundObj = ChartHelper.AddObject("Background", table.transform, table.graphMinAnchor, - table.graphMaxAnchor, table.graphPivot, sizeDelta); - backgroundObj.hideFlags = table.chartHideFlags; + var sizeDelta = component.background.imageWidth > 0 && component.background.imageHeight > 0 ? + new Vector2(component.background.imageWidth, component.background.imageHeight) : + component.graphSizeDelta; + var backgroundObj = ChartHelper.AddObject("Background", component.transform, component.graphMinAnchor, + component.graphMaxAnchor, component.graphPivot, sizeDelta); + backgroundObj.hideFlags = component.chartHideFlags; var backgroundImage = ChartHelper.EnsureComponent(backgroundObj); - ChartHelper.UpdateRectTransform(backgroundObj, table.graphMinAnchor, - table.graphMaxAnchor, table.graphPivot, sizeDelta); - ChartHelper.SetBackground(backgroundImage, table.background); + ChartHelper.UpdateRectTransform(backgroundObj, component.graphMinAnchor, + component.graphMaxAnchor, component.graphPivot, sizeDelta); + ChartHelper.SetBackground(backgroundImage, component.background); backgroundObj.transform.SetSiblingIndex(0); - backgroundObj.SetActive(table.background.show && table.background.image != null); + backgroundObj.SetActive(component.background.show && component.background.image != null); } } } \ No newline at end of file From 2e604529ee47a547ddc53b68a1106645de494e8a Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 4 Dec 2024 09:18:38 +0800 Subject: [PATCH 03/17] =?UTF-8?q?=E5=A4=84=E7=90=86`Unity`=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Utilities/ChartHelper.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index 4e1d72b7..f72c7c99 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -297,7 +297,11 @@ namespace XCharts.Runtime chartText.tmpText.fontStyle = textStyle.tmpFontStyle; chartText.tmpText.richText = true; chartText.tmpText.raycastTarget = false; +#if UNITY_2023_2_OR_NEWER + chartText.tmpText.textWrappingMode = textStyle.autoWrap ? TextWrappingModes.Normal : TextWrappingModes.NoWrap; +#else chartText.tmpText.enableWordWrapping = textStyle.autoWrap; +#endif #else chartText.text = EnsureComponent(txtObj); chartText.text.font = textStyle.font == null ? theme.font : textStyle.font; From f5ec47c105d73c5d74dd03ad0a60bfc6ba97bb51 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 7 Dec 2024 22:21:55 +0800 Subject: [PATCH 04/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Chart`=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=B8=8B=E4=B8=8D=E8=83=BD=E6=94=BE=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=8A=82=E7=82=B9=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 3 ++- .../Axis/AngleAxis/AngleAxisHandler.cs | 2 +- Runtime/Component/Axis/AxisHandler.cs | 4 ++-- .../Axis/RadiusAxis/RadiusAxisHandler.cs | 2 +- .../Component/Background/BackgroundHandler.cs | 2 +- Runtime/Component/Comment/CommentHander.cs | 2 +- Runtime/Component/DataZoom/DataZoomHandler.cs | 2 +- Runtime/Component/Debug/DebugInfo.cs | 6 ++--- Runtime/Component/Legend/LegendHandler.cs | 2 +- Runtime/Component/Legend/LegendHelper.cs | 2 +- Runtime/Component/Mark/MarkAreaHandler.cs | 2 +- Runtime/Component/Mark/MarkLineHandler.cs | 2 +- Runtime/Component/Radar/RadarCoordHandler.cs | 2 +- Runtime/Component/Title/TitleHandler.cs | 2 +- Runtime/Component/Tooltip/TooltipHandler.cs | 2 +- Runtime/Internal/BaseChart.cs | 6 ++--- Runtime/Internal/BaseGraph.API.cs | 4 ++-- Runtime/Internal/BaseGraph.cs | 5 +++- Runtime/Internal/Utilities/ChartHelper.cs | 23 ++++++++++++++++--- Runtime/Serie/SerieHandler.cs | 2 +- 20 files changed, 49 insertions(+), 28 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 93477538..5457a844 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,7 +78,8 @@ slug: /changelog ## master -* (2024.11.04) 增加`UIText`扩展组件 +* (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题 +* (2024.12.05) 增加`UIText`扩展组件 * (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment` ## v3.12.1 diff --git a/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs b/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs index 8818d016..ce8aa36e 100644 --- a/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs +++ b/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs @@ -67,7 +67,7 @@ namespace XCharts.Runtime string objName = component.GetType().Name + axis.index; var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); axisObj.transform.localPosition = Vector3.zero; axisObj.SetActive(axis.show); axisObj.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index a36ec72b..61b60cdf 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -379,7 +379,7 @@ namespace XCharts chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, - chart.chartSizeDelta); + chart.chartSizeDelta, -1, chart.childrenNodeNames); axisObj.SetActive(axis.show); axisObj.hideFlags = chart.chartHideFlags; @@ -488,7 +488,7 @@ namespace XCharts chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, - chart.chartSizeDelta); + chart.chartSizeDelta, -1, chart.childrenNodeNames); axisObj.SetActive(axis.show); axisObj.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs index 5a84d71f..6feca7f5 100644 --- a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs +++ b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs @@ -99,7 +99,7 @@ namespace XCharts.Runtime var radius = polar.context.outsideRadius - polar.context.insideRadius; var objName = component.GetType().Name + axis.index; var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); axisObj.transform.localPosition = Vector3.zero; axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Component/Background/BackgroundHandler.cs b/Runtime/Component/Background/BackgroundHandler.cs index bb53f759..b79ccd60 100644 --- a/Runtime/Component/Background/BackgroundHandler.cs +++ b/Runtime/Component/Background/BackgroundHandler.cs @@ -15,7 +15,7 @@ namespace XCharts.Runtime component.refreshComponent = delegate () { var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); component.gameObject = backgroundObj; backgroundObj.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Component/Comment/CommentHander.cs b/Runtime/Component/Comment/CommentHander.cs index 1fc580e4..b0d06eb5 100644 --- a/Runtime/Component/Comment/CommentHander.cs +++ b/Runtime/Component/Comment/CommentHander.cs @@ -22,7 +22,7 @@ namespace XCharts.Runtime chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, - chart.chartSizeDelta); + chart.chartSizeDelta, -1, chart.childrenNodeNames); commentObj.SetActive(comment.show); commentObj.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Component/DataZoom/DataZoomHandler.cs b/Runtime/Component/DataZoom/DataZoomHandler.cs index cfbeaf43..14b78906 100644 --- a/Runtime/Component/DataZoom/DataZoomHandler.cs +++ b/Runtime/Component/DataZoom/DataZoomHandler.cs @@ -27,7 +27,7 @@ namespace XCharts.Runtime dataZoom.refreshComponent = delegate () { var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform, - chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); dataZoom.gameObject = dataZoomObject; dataZoomObject.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(dataZoomObject); diff --git a/Runtime/Component/Debug/DebugInfo.cs b/Runtime/Component/Debug/DebugInfo.cs index 966d7a98..e7aa0849 100644 --- a/Runtime/Component/Debug/DebugInfo.cs +++ b/Runtime/Component/Debug/DebugInfo.cs @@ -75,7 +75,7 @@ namespace XCharts.Runtime public void Init(BaseChart chart) { m_Chart = chart; - m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme); + m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme, chart.childrenNodeNames); } public void Update() @@ -155,14 +155,14 @@ namespace XCharts.Runtime } private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle, - ThemeStyle theme) + ThemeStyle theme, List childrenNodeNames) { var anchorMax = new Vector2(0, 1); var anchorMin = new Vector2(0, 1); var pivot = new Vector2(0, 1); var sizeDelta = new Vector2(100, 100); - var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); + var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childrenNodeNames); labelGameObject.transform.SetAsLastSibling(); labelGameObject.hideFlags = m_Chart.chartHideFlags; ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo); diff --git a/Runtime/Component/Legend/LegendHandler.cs b/Runtime/Component/Legend/LegendHandler.cs index aa830414..f098c929 100644 --- a/Runtime/Component/Legend/LegendHandler.cs +++ b/Runtime/Component/Legend/LegendHandler.cs @@ -55,7 +55,7 @@ namespace XCharts.Runtime { legend.OnChanged(); var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); legend.gameObject = legendObject; legendObject.hideFlags = chart.chartHideFlags; //ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_"); diff --git a/Runtime/Component/Legend/LegendHelper.cs b/Runtime/Component/Legend/LegendHelper.cs index 1ee362e3..ffc55f36 100644 --- a/Runtime/Component/Legend/LegendHelper.cs +++ b/Runtime/Component/Legend/LegendHelper.cs @@ -48,7 +48,7 @@ namespace XCharts.Runtime var objAnchorMin = new Vector2(0, 1); var objAnchorMax = new Vector2(0, 1); var objPivot = new Vector2(0, 1); - var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta); + var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, -1, chart.childrenNodeNames); var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta); var img = ChartHelper.EnsureComponent(btnObj); img.color = Color.clear; diff --git a/Runtime/Component/Mark/MarkAreaHandler.cs b/Runtime/Component/Mark/MarkAreaHandler.cs index 98b9f6c9..df8eb1f9 100644 --- a/Runtime/Component/Mark/MarkAreaHandler.cs +++ b/Runtime/Component/Mark/MarkAreaHandler.cs @@ -14,7 +14,7 @@ namespace XCharts.Runtime public override void InitComponent() { m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(m_MarkLineLabelRoot); InitMarkArea(component); diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs index fcdb7a3c..ccf6cf1b 100644 --- a/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Runtime/Component/Mark/MarkLineHandler.cs @@ -13,7 +13,7 @@ namespace XCharts.Runtime public override void InitComponent() { m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(m_MarkLineLabelRoot); InitMarkLine(component); diff --git a/Runtime/Component/Radar/RadarCoordHandler.cs b/Runtime/Component/Radar/RadarCoordHandler.cs index 15d3740b..3b820d39 100644 --- a/Runtime/Component/Radar/RadarCoordHandler.cs +++ b/Runtime/Component/Radar/RadarCoordHandler.cs @@ -41,7 +41,7 @@ namespace XCharts.Runtime { radar.UpdateRadarCenter(chart); var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); radar.gameObject = radarObject; radar.gameObject.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT); diff --git a/Runtime/Component/Title/TitleHandler.cs b/Runtime/Component/Title/TitleHandler.cs index d1556c83..9f789aba 100644 --- a/Runtime/Component/Title/TitleHandler.cs +++ b/Runtime/Component/Title/TitleHandler.cs @@ -22,7 +22,7 @@ namespace XCharts.Runtime var pivot = title.location.runtimePivot; var objName = ChartCached.GetComponentObjectName(title); var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax, - pivot, chart.chartSizeDelta); + pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); title.gameObject = titleObject; title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1); anchorMin = title.location.runtimeAnchorMin; diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index 21787aa1..449b7991 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -53,7 +53,7 @@ namespace XCharts.Runtime { var objName = ChartCached.GetComponentObjectName(tooltip); tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); var tooltipObject = tooltip.gameObject; tooltipObject.transform.localPosition = Vector3.zero; tooltipObject.hideFlags = chart.chartHideFlags; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index e661013b..df21b6f9 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -394,7 +394,7 @@ namespace XCharts.Runtime { var index = settings.reversePainter ? settings.maxPainter - 1 - i : i; var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor, - m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index); + m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index, m_ChildNodeNames); painter.index = m_PainterList.Count; painter.type = Painter.Type.Serie; painter.onPopulateMesh = OnDrawPainterSerie; @@ -404,7 +404,7 @@ namespace XCharts.Runtime m_PainterList.Add(painter); } m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor, - m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter); + m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames); m_PainterUpper.type = Painter.Type.Top; m_PainterUpper.onPopulateMesh = OnDrawPainterUpper; m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject); @@ -412,7 +412,7 @@ namespace XCharts.Runtime m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1); m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor, - m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter); + m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames); m_PainterTop.type = Painter.Type.Top; m_PainterTop.onPopulateMesh = OnDrawPainterTop; m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject); diff --git a/Runtime/Internal/BaseGraph.API.cs b/Runtime/Internal/BaseGraph.API.cs index 210d681e..90c9adce 100644 --- a/Runtime/Internal/BaseGraph.API.cs +++ b/Runtime/Internal/BaseGraph.API.cs @@ -158,8 +158,8 @@ namespace XCharts.Runtime /// public void RebuildChartObject() { - ChartHelper.DestroyAllChildren(transform); - SetAllComponentDirty(); + ChartHelper.DestoryGameObjectByMatch(transform, m_ChildNodeNames); + //SetAllComponentDirty(); } public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint) diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index 2bf81ac1..23de7149 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; @@ -14,6 +15,7 @@ namespace XCharts.Runtime IDragHandler, IEndDragHandler, IScrollHandler { [SerializeField] protected bool m_EnableTextMeshPro = false; + [SerializeField] protected List m_ChildNodeNames = new List(); protected Painter m_Painter; protected int m_SiblingIndex; @@ -54,6 +56,7 @@ namespace XCharts.Runtime private ScrollRect m_ScrollRect; public Painter painter { get { return m_Painter; } } + public List childrenNodeNames { get { return m_ChildNodeNames; } } protected virtual void InitComponent() { @@ -158,7 +161,7 @@ namespace XCharts.Runtime protected virtual void InitPainter() { m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor, - m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1); + m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1, m_ChildNodeNames); m_Painter.type = Painter.Type.Base; m_Painter.onPopulateMesh = OnDrawPainterBase; m_Painter.transform.SetSiblingIndex(0); diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index f72c7c99..dc138d23 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -156,6 +156,21 @@ namespace XCharts.Runtime } } + public static void DestoryGameObjectByMatch(Transform parent, List children) + { + if (parent == null) return; + if (children == null || children.Count == 0) return; + var childCount = parent.childCount; + for (int i = childCount - 1; i >= 0; i--) + { + var go = parent.GetChild(i); + if (go != null && children.Contains(go.name)) + { + GameObject.DestroyImmediate(go.gameObject, true); + } + } + } + public static void DestoryGameObject(GameObject go) { if (go != null) GameObject.DestroyImmediate(go, true); @@ -233,7 +248,7 @@ namespace XCharts.Runtime } public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin, - Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1) + Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1, List cacheNames = null) { GameObject obj; if (parent.Find(name)) @@ -267,6 +282,8 @@ namespace XCharts.Runtime rect.anchorMax = anchorMax; rect.pivot = pivot; rect.anchoredPosition3D = Vector3.zero; + + if (cacheNames != null && !cacheNames.Contains(name)) cacheNames.Add(name); return obj; } @@ -332,9 +349,9 @@ namespace XCharts.Runtime } public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, - Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex) + Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex, List childNodeNames) { - var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); + var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childNodeNames); painterObj.hideFlags = hideFlags; painterObj.transform.SetSiblingIndex(siblingIndex); return ChartHelper.EnsureComponent(painterObj); diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 52b57a1a..b24f4e22 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -314,7 +314,7 @@ namespace XCharts.Runtime } var objName = s_SerieRootObjectName + "_" + serie.index; m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, - chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames); m_SerieRoot.hideFlags = chart.chartHideFlags; ChartHelper.SetActive(m_SerieRoot, true); ChartHelper.HideAllObject(m_SerieRoot); From 33b71dc71157ab4cb59d45ab81327022e5b7e275 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 10 Dec 2024 08:49:41 +0800 Subject: [PATCH 05/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`UIToggle`=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 2 ++ Runtime/Component/Child/BorderStyle.cs | 6 ++++++ Runtime/Internal/UIComponent.cs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5457a844..366b47ab 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,8 @@ slug: /changelog ## master +* (2024.12.10) 增加`UIToggle`扩展组件 +* (2024.12.09) 修复`UITable`的`scrollbar`无法拖动的问题 * (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题 * (2024.12.05) 增加`UIText`扩展组件 * (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment` diff --git a/Runtime/Component/Child/BorderStyle.cs b/Runtime/Component/Child/BorderStyle.cs index 6ef2124c..2a828ad5 100644 --- a/Runtime/Component/Child/BorderStyle.cs +++ b/Runtime/Component/Child/BorderStyle.cs @@ -82,5 +82,11 @@ namespace XCharts.Runtime { return m_Show && roundedCorner ? m_CornerRadius : null; } + + public bool IsCricle() + { + return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 && + m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1; + } } } \ No newline at end of file diff --git a/Runtime/Internal/UIComponent.cs b/Runtime/Internal/UIComponent.cs index ab3ab1dc..43916eeb 100644 --- a/Runtime/Internal/UIComponent.cs +++ b/Runtime/Internal/UIComponent.cs @@ -14,7 +14,7 @@ namespace XCharts.Runtime { [SerializeField] private bool m_DebugModel = false; [SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme(); - [SerializeField] private Background m_Background = new Background() { show = true }; + [SerializeField] protected Background m_Background = new Background() { show = true }; protected bool m_DataDirty; private ThemeType m_CheckTheme = 0; From 2fc87d03cd42ac82b41c3b9e3e1e9b282e935741 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 17 Dec 2024 22:19:22 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`UISlider`=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Background/Background.cs | 6 ++++++ Runtime/Internal/Utilities/UIHelper.cs | 18 ++++++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 366b47ab..b14f23d3 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.17) 增加`UISlider`扩展组件 * (2024.12.10) 增加`UIToggle`扩展组件 * (2024.12.09) 修复`UITable`的`scrollbar`无法拖动的问题 * (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题 diff --git a/Runtime/Component/Background/Background.cs b/Runtime/Component/Background/Background.cs index bce23b29..c6ee38f7 100644 --- a/Runtime/Component/Background/Background.cs +++ b/Runtime/Component/Background/Background.cs @@ -100,6 +100,12 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); } } + /// + /// the rect of background. + /// ||背景的矩形区域。 + /// + public Rect rect { get; set; } + public override void SetDefaultValue() { m_Show = true; diff --git a/Runtime/Internal/Utilities/UIHelper.cs b/Runtime/Internal/Utilities/UIHelper.cs index 592df19c..781fd944 100644 --- a/Runtime/Internal/Utilities/UIHelper.cs +++ b/Runtime/Internal/Utilities/UIHelper.cs @@ -14,16 +14,30 @@ namespace XCharts.Runtime internal static void DrawBackground(VertexHelper vh, UIComponent component) { var background = component.background; + var rect = component.graphRect; + if (background.imageWidth > 0 || background.imageHeight > 0) + { + if (background.imageWidth > 0) + { + rect.width = background.imageWidth; + rect.x = component.graphX + (component.graphWidth - background.imageWidth) / 2; + } + if (background.imageHeight > 0) + { + rect.height = background.imageHeight; + rect.y = component.graphY + (component.graphHeight - background.imageHeight) / 2; + } + } + background.rect = rect; if (!background.show) return; if (background.image != null) return; - var backgroundColor = component.theme.GetBackgroundColor(background); var borderWidth = background.borderStyle.GetRuntimeBorderWidth(); var borderColor = background.borderStyle.GetRuntimeBorderColor(); var cornerRadius = background.borderStyle.GetRuntimeCornerRadius(); - UGL.DrawRoundRectangleWithBorder(vh, component.graphRect, backgroundColor, backgroundColor, cornerRadius, + UGL.DrawRoundRectangleWithBorder(vh, background.rect, backgroundColor, backgroundColor, cornerRadius, borderWidth, borderColor); } From 301c66eccf27739f6069f6919796c7d26b43dec8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 23 Dec 2024 21:29:39 +0800 Subject: [PATCH 07/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/BaseChart.Draw.cs | 4 ++-- Runtime/Internal/BaseGraph.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Runtime/Internal/BaseChart.Draw.cs b/Runtime/Internal/BaseChart.Draw.cs index f23303be..c9f2247b 100644 --- a/Runtime/Internal/BaseChart.Draw.cs +++ b/Runtime/Internal/BaseChart.Draw.cs @@ -54,8 +54,8 @@ namespace XCharts.Runtime p4 = ClampInGrid(grid, p4); } if (!clip || - (clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) && - grid.Contains(p4)))) + (clip && grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) && + grid.Contains(p4))) UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor); } diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index 23de7149..8f0f7659 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -54,9 +54,11 @@ namespace XCharts.Runtime public virtual HideFlags chartHideFlags { get { return HideFlags.None; } } private ScrollRect m_ScrollRect; + private Vector2 m_PointerDownPos; public Painter painter { get { return m_Painter; } } public List childrenNodeNames { get { return m_ChildNodeNames; } } + public bool isDragingClick { get; set; } protected virtual void InitComponent() { @@ -287,11 +289,13 @@ namespace XCharts.Runtime public virtual void OnPointerDown(PointerEventData eventData) { + m_PointerDownPos = eventData.position; if (m_OnPointerDown != null) m_OnPointerDown(eventData, this); } public virtual void OnPointerUp(PointerEventData eventData) { + isDragingClick = Vector2.Distance(eventData.position, m_PointerDownPos) > 6; if (m_OnPointerUp != null) m_OnPointerUp(eventData, this); } From 5d24580725c1eabdf916afe9753e290aae629af8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 23 Dec 2024 21:31:27 +0800 Subject: [PATCH 08/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`SymbolStyle`=E7=9A=84`?= =?UTF-8?q?borderWidth`=E5=92=8C`emptyColor`=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/ChildComponents/SymbolStyleDrawer.cs | 2 ++ Editor/Utilities/ChartEditorHelper.cs | 12 +++++++++--- Runtime/Component/Child/SymbolStyle.cs | 20 ++++++++++++++++++++ Runtime/Internal/Utilities/ChartDrawer.cs | 7 ++++++- Runtime/Utilities/ColorUtil.cs | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index b14f23d3..56a4e7cb 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.23) 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置 * (2024.12.17) 增加`UISlider`扩展组件 * (2024.12.10) 增加`UIToggle`扩展组件 * (2024.12.09) 修复`UITable`的`scrollbar`无法拖动的问题 diff --git a/Editor/ChildComponents/SymbolStyleDrawer.cs b/Editor/ChildComponents/SymbolStyleDrawer.cs index edd66978..5ce9f31b 100644 --- a/Editor/ChildComponents/SymbolStyleDrawer.cs +++ b/Editor/ChildComponents/SymbolStyleDrawer.cs @@ -28,6 +28,8 @@ namespace XCharts.Editor PropertyField(prop, "m_Color"); PropertyField(prop, "m_Size"); PropertyField(prop, "m_Gap"); + PropertyField(prop, "m_BorderWidth"); + PropertyField(prop, "m_EmptyColor"); PropertyField(prop, "m_Offset"); --EditorGUI.indentLevel; } diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs index afe48c66..27ffdafd 100644 --- a/Editor/Utilities/ChartEditorHelper.cs +++ b/Editor/Utilities/ChartEditorHelper.cs @@ -108,11 +108,11 @@ namespace XCharts.Editor { EditorGUI.LabelField(drawRect, name); var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; - var diff = 13 + EditorGUI.indentLevel * 14; + var diff = 12 + EditorGUI.indentLevel * 14; var offset = diff - INDENT_WIDTH; var tempWidth = (rectWidth - startX + diff) / 2; var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1); - var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1); + var centerYRect = new Rect(centerXRect.x + tempWidth - offset + 3.4f, drawRect.y, tempWidth - 1, drawRect.height - 1); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; @@ -326,7 +326,13 @@ namespace XCharts.Editor var foldoutRect = drawRect; foldoutRect.xMax -= 10; bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true); - ChartEditorHelper.DrawMenu(drawRect, menus); + if (!flag) + { + var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; + var sizeRect = new Rect(startX, drawRect.y + 1f, (EditorGUI.indentLevel + 1) * 15, drawRect.height - 1); + EditorGUI.IntField(sizeRect, GUIContent.none, listProp.arraySize); + DrawMenu(drawRect, menus); + } height += headerHeight; drawRect.y += headerHeight; drawRect.width = rawWidth; diff --git a/Runtime/Component/Child/SymbolStyle.cs b/Runtime/Component/Child/SymbolStyle.cs index 98d62178..cdfa275a 100644 --- a/Runtime/Component/Child/SymbolStyle.cs +++ b/Runtime/Component/Child/SymbolStyle.cs @@ -84,6 +84,8 @@ namespace XCharts.Runtime [SerializeField] protected Sprite m_Image; [SerializeField] protected Image.Type m_ImageType; [SerializeField] protected Color32 m_Color; + [SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f; + [SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor; public virtual void Reset() { @@ -183,6 +185,24 @@ namespace XCharts.Runtime get { return m_Color; } set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); } } + /// + /// the border width of symbol. + /// ||图形的边框宽度。 + /// + public float borderWidth + { + get { return m_BorderWidth; } + set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); } + } + /// + /// the color of empty symbol. + /// ||空心图形的颜色。 + /// + public Color32 emptyColor + { + get { return m_EmptyColor; } + set { if (PropertyUtil.SetStruct(ref m_EmptyColor, value)) SetAllDirty(); } + } public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } } private List m_AnimationSize = new List() { 0, 5, 10 }; /// diff --git a/Runtime/Internal/Utilities/ChartDrawer.cs b/Runtime/Internal/Utilities/ChartDrawer.cs index c6cfbf9b..a57ea361 100644 --- a/Runtime/Internal/Utilities/ChartDrawer.cs +++ b/Runtime/Internal/Utilities/ChartDrawer.cs @@ -22,13 +22,14 @@ namespace XCharts.Runtime } else { - if (tickness > 0) + if (tickness > 0 && !ChartHelper.IsClearColor(borderColor)) UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness); else UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness); } break; case SymbolType.EmptyCircle: + if (tickness == 0) tickness = 4f; if (gap > 0) { UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness); @@ -57,6 +58,7 @@ namespace XCharts.Runtime } break; case SymbolType.EmptyRect: + if (tickness == 0) tickness = 4f; if (gap > 0) { UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); @@ -75,6 +77,7 @@ namespace XCharts.Runtime } if (type == SymbolType.EmptyTriangle) { + if (tickness == 0) tickness = 4f; UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor); } else @@ -92,6 +95,7 @@ namespace XCharts.Runtime } if (type == SymbolType.EmptyDiamond) { + if (tickness == 0) tickness = 4f; UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor); } else @@ -124,6 +128,7 @@ namespace XCharts.Runtime arrowOffset, arrowDent, color); if (type == SymbolType.EmptyArrow) { + if (tickness == 0) tickness = 4f; arrowWidth = (symbolSize - tickness) * 2; arrowHeight = arrowWidth * 1.5f; arrowOffset = 0; diff --git a/Runtime/Utilities/ColorUtil.cs b/Runtime/Utilities/ColorUtil.cs index 3e154b9c..99b9bdc9 100644 --- a/Runtime/Utilities/ColorUtil.cs +++ b/Runtime/Utilities/ColorUtil.cs @@ -7,6 +7,7 @@ namespace XCharts.Runtime { private static Dictionary s_ColorCached = new Dictionary(); public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0); + public static readonly Color32 white = new Color32(255, 255, 255, 255); public static readonly Vector2 zeroVector2 = Vector2.zero; /// From 074c1a3992e7c47b53a47ec753ba107ed32bab5c Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 25 Dec 2024 10:06:53 +0800 Subject: [PATCH 09/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`UISlider`=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Child/Location.cs | 63 +++++++++++++++++++++++ Runtime/Internal/Utilities/ChartHelper.cs | 16 ++++++ Runtime/Internal/Utilities/UIHelper.cs | 13 ++++- 3 files changed, 90 insertions(+), 2 deletions(-) diff --git a/Runtime/Component/Child/Location.cs b/Runtime/Component/Child/Location.cs index 0d49d6c7..ea010f2c 100644 --- a/Runtime/Component/Child/Location.cs +++ b/Runtime/Component/Child/Location.cs @@ -349,6 +349,69 @@ namespace XCharts.Runtime } } + public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight) + { + UpdateRuntimeData(graphWidth, graphWidth); + + float x, y, width, height; + + width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth; + height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight; + + switch (align) + { + case Align.BottomCenter: + x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2; + y = graphY + runtimeBottom; + break; + + case Align.BottomLeft: + x = graphX + runtimeLeft; + y = graphY + runtimeBottom; + break; + + case Align.BottomRight: + x = graphX + graphWidth - runtimeRight - width; + y = graphY + runtimeBottom; + break; + + case Align.Center: + x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2; + y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2; + break; + + case Align.CenterLeft: + x = graphX + runtimeLeft; + y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2; + break; + + case Align.CenterRight: + x = graphX + graphWidth - runtimeRight - width; + y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2; + break; + + case Align.TopCenter: + x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2; + y = graphY + graphHeight - runtimeTop - height; + break; + + case Align.TopLeft: + x = graphX + runtimeLeft; + y = graphY + graphHeight - runtimeTop - height; + break; + + case Align.TopRight: + x = graphX + graphWidth - runtimeRight - width; + y = graphY + graphHeight - runtimeTop - height; + break; + + default: + return new Rect(0, 0, 0, 0); + } + return new Rect(x, y, width, height); + } + + /// /// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot /// diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index dc138d23..c0bef4fc 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -791,6 +791,14 @@ namespace XCharts.Runtime return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate; } + public static float GetMaxCeilRate(float value, float ceilRate) + { + if (ceilRate == 0) return value; + var mod = value % ceilRate; + int rate = (int)(value / ceilRate); + return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate; + } + public static double GetMinCeilRate(double value, double ceilRate) { if (ceilRate == 0) return value; @@ -799,6 +807,14 @@ namespace XCharts.Runtime return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate; } + public static float GetMinCeilRate(float value, float ceilRate) + { + if (ceilRate == 0) return value; + var mod = value % ceilRate; + int rate = (int)(value / ceilRate); + return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate; + } + public static double GetMinDivisibleValue(double min, double ceilRate) { if (min == 0) return 0; diff --git a/Runtime/Internal/Utilities/UIHelper.cs b/Runtime/Internal/Utilities/UIHelper.cs index 781fd944..5fac7f8d 100644 --- a/Runtime/Internal/Utilities/UIHelper.cs +++ b/Runtime/Internal/Utilities/UIHelper.cs @@ -11,7 +11,7 @@ namespace XCharts.Runtime /// public static class UIHelper { - internal static void DrawBackground(VertexHelper vh, UIComponent component) + public static void DrawBackground(VertexHelper vh, UIComponent component) { var background = component.background; var rect = component.graphRect; @@ -34,10 +34,19 @@ namespace XCharts.Runtime if (background.image != null) return; var backgroundColor = component.theme.GetBackgroundColor(background); + DrawBackground(vh, background, backgroundColor); + } + + public static void DrawBackground(VertexHelper vh, Background background, Color32 color) + { + if (!background.show) + return; + if (background.image != null) + return; var borderWidth = background.borderStyle.GetRuntimeBorderWidth(); var borderColor = background.borderStyle.GetRuntimeBorderColor(); var cornerRadius = background.borderStyle.GetRuntimeCornerRadius(); - UGL.DrawRoundRectangleWithBorder(vh, background.rect, backgroundColor, backgroundColor, cornerRadius, + UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius, borderWidth, borderColor); } From d1438dd76fca56c1a60219464c0f4bf6e9fb7c43 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 25 Dec 2024 16:30:25 +0800 Subject: [PATCH 10/17] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`YAxis`=E5=9C=A8?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E5=8F=98=E6=9B=B4=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=83=A8=E5=88=86label=E5=8F=AF=E8=83=BD=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Axis/AxisHandler.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 56a4e7cb..b129d398 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题 * (2024.12.23) 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置 * (2024.12.17) 增加`UISlider`扩展组件 * (2024.12.10) 增加`UIToggle`扩展组件 diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index 61b60cdf..23e69d47 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -372,6 +372,7 @@ namespace XCharts var axisLength = (axis.context.end - axis.context.start).magnitude; if (axisLength == 0) return; chart.InitAxisRuntimeData(axis); + UpdateAxisMinMaxValue(axis.index, axis, true); var objName = ChartCached.GetComponentObjectName(axis); var axisObj = ChartHelper.AddObject(objName, @@ -473,7 +474,6 @@ namespace XCharts break; } } - UpdateAxisMinMaxValue(axis.index, axis, true); } protected void InitAxis(Axis relativedAxis, Orient orient, @@ -481,6 +481,7 @@ namespace XCharts { Axis axis = component; chart.InitAxisRuntimeData(axis); + UpdateAxisMinMaxValue(axis.index, axis, true); var objName = ChartCached.GetComponentObjectName(axis); var axisObj = ChartHelper.AddObject(objName, @@ -637,7 +638,6 @@ namespace XCharts } } } - UpdateAxisMinMaxValue(axis.index, axis, true); } internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme, From 6e9d9bfd3d014a2f51a6ac63c0b6607bd2da58a3 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 25 Dec 2024 21:39:13 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Tooltip`=E7=9A=84`item?= =?UTF-8?q?Formatter`=E8=AE=BE=E7=BD=AE`{f0}`=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Label/SerieLabelHelper.cs | 2 +- Runtime/Component/Tooltip/TooltipHelper.cs | 3 ++- Runtime/Helper/FormatterHelper.cs | 12 ++++++++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index b129d398..782e3cee 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.25) 增加`Tooltip`的`itemFormatter`设置`{f0}`支持 * (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题 * (2024.12.23) 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置 * (2024.12.17) 增加`UISlider`扩展组件 diff --git a/Runtime/Component/Label/SerieLabelHelper.cs b/Runtime/Component/Label/SerieLabelHelper.cs index 2dc111e4..b05ffaae 100644 --- a/Runtime/Component/Label/SerieLabelHelper.cs +++ b/Runtime/Component/Label/SerieLabelHelper.cs @@ -45,7 +45,7 @@ namespace XCharts.Runtime { var content = serieLabel.formatter; FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue, - dataTotal, serieName, dataName, dataName, color, serieData, chart); + dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index); if (serieLabel.formatterFunction == null) return content; else diff --git a/Runtime/Component/Tooltip/TooltipHelper.cs b/Runtime/Component/Tooltip/TooltipHelper.cs index 4b42b71d..467dce83 100644 --- a/Runtime/Component/Tooltip/TooltipHelper.cs +++ b/Runtime/Component/Tooltip/TooltipHelper.cs @@ -44,7 +44,8 @@ namespace XCharts.Runtime param.serieData.name, param.color, param.serieData, - chart); + chart, + param.serieIndex); foreach (var item in content.Split('|')) { param.columns.Add(item); diff --git a/Runtime/Helper/FormatterHelper.cs b/Runtime/Helper/FormatterHelper.cs index 6a9ac8ad..2ab5a4da 100644 --- a/Runtime/Helper/FormatterHelper.cs +++ b/Runtime/Helper/FormatterHelper.cs @@ -149,7 +149,7 @@ namespace XCharts.Runtime else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f') { var isPercent = p == 'd' || p == 'D'; - var isTotal = p == 'f' || p == 'f'; + var isTotal = p == 'f' || p == 'F'; var bIndex = dataIndex; var dimensionIndex = -1; if (argsCount >= 2) @@ -211,7 +211,7 @@ namespace XCharts.Runtime } public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total, - string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null) + string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0) { var mc = s_RegexForSerieLabel.Matches(content); foreach (var m in mc) @@ -270,6 +270,14 @@ namespace XCharts.Runtime } else if (p == 'f' || p == 'f') { + if (pIndex != 1 && chart != null) + { + var serie = chart.GetSerie(serieIndex); + if (serie != null) + { + total = serie.GetDataTotal(pIndex, serieData); + } + } content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter)); } else if (p == 'g' || p == 'G') From d466ac2bc1161f8604f1b7636c1b9e4a9799241b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 26 Dec 2024 10:05:20 +0800 Subject: [PATCH 12/17] =?UTF-8?q?=E4=BC=98=E5=8C=96`Text`=E5=9C=A8`TextMes?= =?UTF-8?q?hPro`=E4=B8=8B=E7=9A=84=E5=B1=85=E4=B8=AD=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Internal/Object/ChartText.cs | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 782e3cee..09b7e64c 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.26) 优化`Text`在`TextMeshPro`下的居中对齐方式 * (2024.12.25) 增加`Tooltip`的`itemFormatter`设置`{f0}`支持 * (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题 * (2024.12.23) 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置 diff --git a/Runtime/Internal/Object/ChartText.cs b/Runtime/Internal/Object/ChartText.cs index fb52dca6..205a611f 100644 --- a/Runtime/Internal/Object/ChartText.cs +++ b/Runtime/Internal/Object/ChartText.cs @@ -187,13 +187,13 @@ namespace XCharts.Runtime m_TMPText.alignment = TextAlignmentOptions.BottomRight; break; case TextAnchor.MiddleCenter: - m_TMPText.alignment = TextAlignmentOptions.Center; + m_TMPText.alignment = TextAlignmentOptions.Midline; break; case TextAnchor.MiddleLeft: - m_TMPText.alignment = TextAlignmentOptions.Left; + m_TMPText.alignment = TextAlignmentOptions.MidlineLeft; break; case TextAnchor.MiddleRight: - m_TMPText.alignment = TextAlignmentOptions.Right; + m_TMPText.alignment = TextAlignmentOptions.MidlineRight; break; case TextAnchor.UpperCenter: m_TMPText.alignment = TextAlignmentOptions.Top; @@ -205,8 +205,7 @@ namespace XCharts.Runtime m_TMPText.alignment = TextAlignmentOptions.TopRight; break; default: - m_TMPText.alignment = TextAlignmentOptions.Center; - m_TextAlignment = TextAnchor.MiddleCenter; + m_TMPText.alignment = TextAlignmentOptions.Midline; break; } #else From 21cd72b9953fd01a7073c9a58fcaae28f1b995c3 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 27 Dec 2024 22:13:35 +0800 Subject: [PATCH 13/17] =?UTF-8?q?=E4=BC=98=E5=8C=96DrawBackground=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Utilities/UIHelper.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Runtime/Internal/Utilities/UIHelper.cs b/Runtime/Internal/Utilities/UIHelper.cs index 5fac7f8d..661d4130 100644 --- a/Runtime/Internal/Utilities/UIHelper.cs +++ b/Runtime/Internal/Utilities/UIHelper.cs @@ -37,7 +37,7 @@ namespace XCharts.Runtime DrawBackground(vh, background, backgroundColor); } - public static void DrawBackground(VertexHelper vh, Background background, Color32 color) + public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2) { if (!background.show) return; @@ -47,7 +47,7 @@ namespace XCharts.Runtime var borderColor = background.borderStyle.GetRuntimeBorderColor(); var cornerRadius = background.borderStyle.GetRuntimeCornerRadius(); UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius, - borderWidth, borderColor); + borderWidth, borderColor, 0, smoothness); } internal static void InitBackground(UIComponent component) From 43de03951cf1260bdd049b91e19543b14d32eaf7 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 28 Dec 2024 21:03:17 +0800 Subject: [PATCH 14/17] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`SymbolStyle`=E7=9A=84`?= =?UTF-8?q?size2`=E5=8F=82=E6=95=B0=E6=94=AF=E6=8C=81=E9=95=BF=E6=96=B9?= =?UTF-8?q?=E5=BD=A2=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/ChildComponents/SymbolStyleDrawer.cs | 1 + Runtime/Component/Child/SymbolStyle.cs | 11 +++++++++ Runtime/Internal/BaseChart.Draw.cs | 12 ++++----- Runtime/Internal/Utilities/ChartDrawer.cs | 26 +++++++++++++------- Runtime/Serie/Heatmap/HeatmapHandler.cs | 4 +-- Runtime/Serie/Line/LineHandler.PolarCoord.cs | 2 +- Runtime/Serie/Radar/RadarHandler.cs | 4 +-- Runtime/Serie/SerieHandler.cs | 2 +- 9 files changed, 42 insertions(+), 21 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 09b7e64c..5cd3957a 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -78,6 +78,7 @@ slug: /changelog ## master +* (2024.12.27) 增加`SymbolStyle`的`size2`参数支持长方形标记 * (2024.12.26) 优化`Text`在`TextMeshPro`下的居中对齐方式 * (2024.12.25) 增加`Tooltip`的`itemFormatter`设置`{f0}`支持 * (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题 diff --git a/Editor/ChildComponents/SymbolStyleDrawer.cs b/Editor/ChildComponents/SymbolStyleDrawer.cs index 5ce9f31b..0ea89711 100644 --- a/Editor/ChildComponents/SymbolStyleDrawer.cs +++ b/Editor/ChildComponents/SymbolStyleDrawer.cs @@ -27,6 +27,7 @@ namespace XCharts.Editor } PropertyField(prop, "m_Color"); PropertyField(prop, "m_Size"); + PropertyField(prop, "m_Size2"); PropertyField(prop, "m_Gap"); PropertyField(prop, "m_BorderWidth"); PropertyField(prop, "m_EmptyColor"); diff --git a/Runtime/Component/Child/SymbolStyle.cs b/Runtime/Component/Child/SymbolStyle.cs index cdfa275a..54e7a63f 100644 --- a/Runtime/Component/Child/SymbolStyle.cs +++ b/Runtime/Component/Child/SymbolStyle.cs @@ -86,12 +86,14 @@ namespace XCharts.Runtime [SerializeField] protected Color32 m_Color; [SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f; [SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor; + [SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f; public virtual void Reset() { m_Show = false; m_Type = SymbolType.EmptyCircle; m_Size = 0f; + m_Size2 = 0f; m_Gap = 0; m_Width = 0f; m_Height = 0f; @@ -128,6 +130,15 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); } } /// + /// the size of symbol. + /// ||标记的大小。当为Rect时,size2表示高度。 + /// + public float size2 + { + get { return m_Size2; } + set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); } + } + /// /// the gap of symbol and line segment. /// ||图形标记和线条的间隙距离。 /// diff --git a/Runtime/Internal/BaseChart.Draw.cs b/Runtime/Internal/BaseChart.Draw.cs index c9f2247b..aef62386 100644 --- a/Runtime/Internal/BaseChart.Draw.cs +++ b/Runtime/Internal/BaseChart.Draw.cs @@ -83,12 +83,12 @@ namespace XCharts.Runtime public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap, - bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos) + bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos, float symbolSize2 = 0) { if (!IsInChart(pos)) return; if (!clip || (clip && (grid.Contains(pos)))) DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor, - gap, cornerRadius, startPos); + gap, cornerRadius, startPos, symbolSize2); } public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth, @@ -101,22 +101,22 @@ namespace XCharts.Runtime public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, - float gap, float[] cornerRadius) + float gap, float[] cornerRadius, float symbolSize2 = 0) { DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor, - gap, cornerRadius, Vector3.zero); + gap, cornerRadius, Vector3.zero, symbolSize2); } public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, - float gap, float[] cornerRadius, Vector3 startPos) + float gap, float[] cornerRadius, Vector3 startPos, float symbolSize2 = 0) { var backgroundColor = GetChartBackgroundColor(); if (ChartHelper.IsClearColor(emptyColor)) emptyColor = backgroundColor; var smoothness = settings.cicleSmoothness; ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, - cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos); + cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos, symbolSize2); } public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid) diff --git a/Runtime/Internal/Utilities/ChartDrawer.cs b/Runtime/Internal/Utilities/ChartDrawer.cs index a57ea361..baffa0f3 100644 --- a/Runtime/Internal/Utilities/ChartDrawer.cs +++ b/Runtime/Internal/Utilities/ChartDrawer.cs @@ -9,7 +9,8 @@ namespace XCharts.Runtime { public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius, - Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, Vector3 startPos) + Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, + Vector3 startPos, float symbolSize2 = 0f) { switch (type) { @@ -41,24 +42,31 @@ namespace XCharts.Runtime } break; case SymbolType.Rect: - if (gap > 0) + if (symbolSize2 > 0 && symbolSize2 != symbolSize) { - UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); - UGL.DrawSquare(vh, pos, symbolSize, color, toColor); + UGL.DrawRectangle(vh, pos, symbolSize, symbolSize2, color, toColor); } else { - if (tickness > 0) + if (gap > 0) { - UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true); - UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius); + UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); + UGL.DrawSquare(vh, pos, symbolSize, color, toColor); } else - UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true); + { + if (tickness > 0) + { + UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true); + UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius); + } + else + UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true); + } } break; case SymbolType.EmptyRect: - if (tickness == 0) tickness = 4f; + if (tickness == 0) tickness = 4f; if (gap > 0) { UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); diff --git a/Runtime/Serie/Heatmap/HeatmapHandler.cs b/Runtime/Serie/Heatmap/HeatmapHandler.cs index 4bb2c784..45554e43 100644 --- a/Runtime/Serie/Heatmap/HeatmapHandler.cs +++ b/Runtime/Serie/Heatmap/HeatmapHandler.cs @@ -303,7 +303,7 @@ namespace XCharts.Runtime var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state); serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, - color, color, emptyColor, borderColor, symbol.gap, cornerRadius); + color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2); } if (visualMap.hoverLink && highlight && emphasisStyle != null && @@ -461,7 +461,7 @@ namespace XCharts.Runtime else { chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, - color, color, emptyColor, borderColor, symbol.gap, cornerRadius); + color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2); } if (visualMap.hoverLink && highlight && emphasisStyle != null && diff --git a/Runtime/Serie/Line/LineHandler.PolarCoord.cs b/Runtime/Serie/Line/LineHandler.PolarCoord.cs index e6e8b9cd..5a014c06 100644 --- a/Runtime/Serie/Line/LineHandler.PolarCoord.cs +++ b/Runtime/Serie/Line/LineHandler.PolarCoord.cs @@ -275,7 +275,7 @@ namespace XCharts.Runtime symbolSize = serie.animation.GetSysmbolSize(symbolSize); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position, - symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); + symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2); } } } diff --git a/Runtime/Serie/Radar/RadarHandler.cs b/Runtime/Serie/Radar/RadarHandler.cs index fbd56eb4..9d97512b 100644 --- a/Runtime/Serie/Radar/RadarHandler.cs +++ b/Runtime/Serie/Radar/RadarHandler.cs @@ -345,7 +345,7 @@ namespace XCharts.Runtime SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState); SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor, - symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); + symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2); } } } @@ -495,7 +495,7 @@ namespace XCharts.Runtime symbolToColor = m_RadarCoord.outRangeColor; } chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor, - symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius); + symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius, serie.symbol.size2); } } if (!serie.animation.IsFinish()) diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index b24f4e22..7c576fb2 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -762,7 +762,7 @@ namespace XCharts.Runtime { var color = symbol.GetColor(defaultColor); chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos, - color, color, ColorUtil.clearColor32, color, symbol.gap, null); + color, color, ColorUtil.clearColor32, color, symbol.gap, null, symbol.size2); } public override void OnPointerDown(PointerEventData eventData) From be6a91b4c2a0f5e8cb43207fb176a472b94babd7 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 31 Dec 2024 08:44:57 +0800 Subject: [PATCH 15/17] 3.13.0 --- Documentation~/zh/changelog.md | 2 -- Runtime/Internal/XChartsMgr.cs | 4 ++-- package.json | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5cd3957a..99dc464a 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -165,8 +165,6 @@ slug: /changelog 日志详情: - - * (2024.06.16) 发布`v3.11.0`版本 * (2024.06.15) 增加`Editor`下`Data`的添加、删除、上下移动操作按钮 * (2024.06.11) 修复`Axis`的`IndicatorLabel`可能会遮挡住`Tooltip`的问题 diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index 98e73c7f..b3c62458 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -21,8 +21,8 @@ namespace XCharts.Runtime [ExecuteInEditMode] public static class XChartsMgr { - public static readonly string version = "3.12.1"; - public static readonly int versionDate = 20241201; + public static readonly string version = "3.13.0"; + public static readonly int versionDate = 20250101; public static string fullVersion { get { return version + "-" + versionDate; } } internal static List chartList = new List(); diff --git a/package.json b/package.json index 8c498357..68b52142 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "displayName": "XCharts", "author": "monitor1394", "license": "MIT", - "version": "3.12.1", - "date": "20241201", - "checkdate": "20241201", + "version": "3.13.0", + "date": "20250101", + "checkdate": "20250101", "unity": "2018.3", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "keywords": [ From 151ed168b59b3750ae19dd0aa9e23c87c7981201 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 1 Jan 2025 20:15:29 +0800 Subject: [PATCH 16/17] 3.13.0 --- Documentation~/en/api.md | 35 +++++++++++++++++++++++++++--- Documentation~/en/changelog.md | 25 +++++++++++++++++++++ Documentation~/en/configuration.md | 22 +++++++++++++++---- Documentation~/zh/api.md | 35 +++++++++++++++++++++++++++--- Documentation~/zh/changelog.md | 16 ++++++++++++++ Documentation~/zh/configuration.md | 22 +++++++++++++++---- 6 files changed, 141 insertions(+), 14 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index dd4ccd19..4d333b91 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -1362,6 +1362,11 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) Background component. +### Background.rect + +public Rect rect +the rect of background. + ### Background.SetDefaultValue public override void SetDefaultValue() @@ -2353,6 +2358,10 @@ class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d public virtual HideFlags chartHideFlags +### BaseGraph.childrenNodeNames + +public List<string> childrenNodeNames + ### BaseGraph.clickPos public Vector2 clickPos @@ -2411,6 +2420,10 @@ The x of graph. public float graphY The y of graph. +### BaseGraph.isDragingClick + +public bool isDragingClick + ### BaseGraph.isPointerClick public bool isPointerClick @@ -2759,6 +2772,10 @@ public float GetRuntimeBorderWidth() public float[] GetRuntimeCornerRadius() +### BorderStyle.IsCricle + +public bool IsCricle() + ## CalendarCoord class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) @@ -2893,7 +2910,8 @@ public static void DestoryGameObject(GameObject go) ### ChartHelper.DestoryGameObjectByMatch -public static void DestoryGameObjectByMatch(Transform parent, string containString) +public static void DestoryGameObjectByMatch(Transform parent, List<string> children) + ### ChartHelper.DestroyAllChildren @@ -2940,7 +2958,8 @@ public static Vector3 GetLastValue(List<Vector3> list) ### ChartHelper.GetMaxCeilRate -public static double GetMaxCeilRate(double value, double ceilRate) +public static float GetMaxCeilRate(float value, float ceilRate) + ### ChartHelper.GetMaxDivisibleValue @@ -2952,7 +2971,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE ### ChartHelper.GetMinCeilRate -public static double GetMinCeilRate(double value, double ceilRate) +public static float GetMinCeilRate(float value, float ceilRate) + ### ChartHelper.GetMinDivisibleValue @@ -5317,6 +5337,10 @@ public float runtimeTop public Vector3 GetPosition(float chartWidth, float chartHeight) 返回在坐标系中的具体位置 +### Location.GetRect + +public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight) + ### Location.IsBottom public bool IsBottom() @@ -9087,6 +9111,11 @@ class in XCharts.Runtime UI帮助类。 +### UIHelper.DrawBackground + +public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2) + + ## ViewControl class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) diff --git a/Documentation~/en/changelog.md b/Documentation~/en/changelog.md index 4acc2e5c..b02b966e 100644 --- a/Documentation~/en/changelog.md +++ b/Documentation~/en/changelog.md @@ -77,6 +77,31 @@ slug: /changelog ## master +Key Features: + +* Added the `UIText` extension component +* Added the `UIToggle` extension component +* Added the `UISlider` extension component +* Refactored the `UIProgress` extension component +* Added `borderWidth` and `emptyColor` configurations to `SymbolStyle` +* Added the `size2` parameter to `SymbolStyle` to support rectangular markers +* Other optimizations and bug fixes + +Detailed Changelog: + +* (2025.01.01) Released `v3.13.0` +* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers +* (2024.12.26) Optimized `Text` alignment in `TextMeshPro` for proper centering +* (2024.12.25) Added support for `{f0}` in the `Tooltip`'s `itemFormatter` setting +* (2024.12.25) Fixed an issue where some labels on the `YAxis` might not display during range refresh +* (2024.12.23) Added `borderWidth` and `emptyColor` configurations to `SymbolStyle` +* (2024.12.17) Added the `UISlider` extension component +* (2024.12.10) Added the `UIToggle` extension component +* (2024.12.09) Fixed an issue where the `UITable`'s `scrollbar` could not be dragged +* (2024.12.07) Fixed an issue where custom nodes could not be placed under the `Chart` node +* (2024.12.05) Added the `UIText` extension component +* (2024.12.04) Removed the unused `tmpAlignment` option from `TextStyle` + ## v3.12.1 Version Highlights: diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index 80e49047..3668730f 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -4366,12 +4366,24 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) / Su 系列数据项的标记的图形 +### SymbolStyle.borderWidth + +`float` `0f` `v3.13.0` + +the border width of symbol. + ### SymbolStyle.color `Color32` 图形的颜色。 +### SymbolStyle.emptyColor + +`Color32` `v3.13.0` + +the color of empty symbol. + ### SymbolStyle.gap `float` `0` @@ -4414,6 +4426,12 @@ Whether the symbol is showed. the size of symbol. +### SymbolStyle.size2 + +`float` `0f` `v3.13.0` + +the size of symbol. + ### SymbolStyle.type [SymbolType](#symboltype) @@ -4551,10 +4569,6 @@ Rotation of text. Settings related to text. -### TextStyle.tMPAlignment - -`TextAlignmentOptions` - ### TextStyle.tMPFont `TMP_FontAsset` diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 5a7d7425..2afbafb9 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -1362,6 +1362,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) 背景组件。 +### Background.rect + +public Rect rect +背景的矩形区域。 + ### Background.SetDefaultValue public override void SetDefaultValue() @@ -2353,6 +2358,10 @@ class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com public virtual HideFlags chartHideFlags +### BaseGraph.childrenNodeNames + +public List<string> childrenNodeNames + ### BaseGraph.clickPos public Vector2 clickPos @@ -2411,6 +2420,10 @@ public float graphX public float graphY 图形的Y +### BaseGraph.isDragingClick + +public bool isDragingClick + ### BaseGraph.isPointerClick public bool isPointerClick @@ -2759,6 +2772,10 @@ public float GetRuntimeBorderWidth() public float[] GetRuntimeCornerRadius() +### BorderStyle.IsCricle + +public bool IsCricle() + ## CalendarCoord class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) @@ -2893,7 +2910,8 @@ public static void DestoryGameObject(GameObject go) ### ChartHelper.DestoryGameObjectByMatch -public static void DestoryGameObjectByMatch(Transform parent, string containString) +public static void DestoryGameObjectByMatch(Transform parent, List<string> children) + ### ChartHelper.DestroyAllChildren @@ -2940,7 +2958,8 @@ public static Vector3 GetLastValue(List<Vector3> list) ### ChartHelper.GetMaxCeilRate -public static double GetMaxCeilRate(double value, double ceilRate) +public static float GetMaxCeilRate(float value, float ceilRate) + ### ChartHelper.GetMaxDivisibleValue @@ -2952,7 +2971,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE ### ChartHelper.GetMinCeilRate -public static double GetMinCeilRate(double value, double ceilRate) +public static float GetMinCeilRate(float value, float ceilRate) + ### ChartHelper.GetMinDivisibleValue @@ -5317,6 +5337,10 @@ public float runtimeTop public Vector3 GetPosition(float chartWidth, float chartHeight) 返回在坐标系中的具体位置 +### Location.GetRect + +public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight) + ### Location.IsBottom public bool IsBottom() @@ -9087,6 +9111,11 @@ class in XCharts.Runtime UI帮助类。 +### UIHelper.DrawBackground + +public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2) + + ## ViewControl class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 99dc464a..4f4657a2 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -6,6 +6,7 @@ slug: /changelog # 更新日志 [master](#master) +[v3.13.0](#v3130) [v3.12.1](#v3121) [v3.12.0](#v3120) [v3.11.2](#v3112) @@ -78,6 +79,21 @@ slug: /changelog ## master +## v3.13.0 + +版本要点: + +* 新增`UIText`扩展组件 +* 新增`UIToggle`扩展组件 +* 新增`UISlider`扩展组件 +* 重构`UIProgress`扩展组件 +* 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置 +* 增加`SymbolStyle`的`size2`参数支持长方形标记 +* 其他优化和问题修复 + +日志详情: + +* (2025.01.01) 发布`v3.13.0`版本 * (2024.12.27) 增加`SymbolStyle`的`size2`参数支持长方形标记 * (2024.12.26) 优化`Text`在`TextMeshPro`下的居中对齐方式 * (2024.12.25) 增加`Tooltip`的`itemFormatter`设置`{f0}`支持 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 9514a70b..c0f85e72 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -4366,12 +4366,24 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类 系列数据项的标记的图形 +### SymbolStyle.borderWidth + +`float` `0f` `v3.13.0` + +图形的边框宽度。 + ### SymbolStyle.color `Color32` 图形的颜色。 +### SymbolStyle.emptyColor + +`Color32` `v3.13.0` + +空心图形的颜色。 + ### SymbolStyle.gap `float` `0` @@ -4414,6 +4426,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类 标记的大小。 +### SymbolStyle.size2 + +`float` `0f` `v3.13.0` + +标记的大小。当为Rect时,size2表示高度。 + ### SymbolStyle.type [SymbolType](#symboltype) @@ -4551,10 +4569,6 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) 文本的相关设置。 -### TextStyle.tMPAlignment - -`TextAlignmentOptions` - ### TextStyle.tMPFont `TMP_FontAsset` From 3db02b86b45e01b77aee3a85ecb2b9c25733d6f8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 1 Jan 2025 22:52:48 +0800 Subject: [PATCH 17/17] 3.13.0 --- Documentation~/en/changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation~/en/changelog.md b/Documentation~/en/changelog.md index b02b966e..46057a4c 100644 --- a/Documentation~/en/changelog.md +++ b/Documentation~/en/changelog.md @@ -6,6 +6,7 @@ slug: /changelog # Changelog [master](#master) +[v3.13.0](#v3130) [v3.12.1](#v3121) [v3.12.0](#v3120) [v3.11.2](#v3112) @@ -77,6 +78,8 @@ slug: /changelog ## master +## v3.13.0 + Key Features: * Added the `UIText` extension component