diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 07fcd601..13d99ad4 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -2,6 +2,7 @@ # 更新日志 [master](#master) +[v2.2.3](#v2.2.3) [v2.2.2](#v2.2.2) [v2.2.1](#v2.2.1) [v2.2.0](#v2.2.0) @@ -37,6 +38,11 @@ ## master +# # v2.2.3 + +* (2021.06.20) Release `v2.2.3` version +* (2021.06.20) Fixed the default display of `Icon` in `Axis` + ## v2.2.2 * (2021.06.18) Release `v2.2.2` version diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index 023d0b8b..5df14777 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -2,6 +2,7 @@ # 更新日志 [master](#master) +[v2.2.3](#v2.2.3) [v2.2.2](#v2.2.2) [v2.2.1](#v2.2.1) [v2.2.0](#v2.2.0) @@ -37,6 +38,11 @@ ## master +## v2.2.3 + +* (2021.06.20) 发布`v2.2.3`版本 +* (2021.06.20) 修复`Axis`的`Icon`默认显示出来的问题 + ## v2.2.2 * (2021.06.18) 发布`v2.2.2`版本 diff --git a/Assets/XCharts/Runtime/Internal/CoordinateChart.cs b/Assets/XCharts/Runtime/Internal/CoordinateChart.cs index b434d5b7..0363c835 100644 --- a/Assets/XCharts/Runtime/Internal/CoordinateChart.cs +++ b/Assets/XCharts/Runtime/Internal/CoordinateChart.cs @@ -575,19 +575,20 @@ namespace XCharts if ((inside && yAxis.IsLeft()) || (!inside && yAxis.IsRight())) { txt = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, Vector2.zero, - Vector2.zero, new Vector2(0, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis); + Vector2.zero, new Vector2(0, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis, + labelName, true); txt.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleLeft)); } else { txt = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, Vector2.zero, - Vector2.zero, new Vector2(1, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis); + Vector2.zero, new Vector2(1, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis, + labelName, true); txt.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleRight)); } var labelWidth = AxisHelper.GetScaleWidth(yAxis, grid.runtimeHeight, i + 1, dataZoom); if (i == 0) yAxis.axisLabel.SetRelatedText(txt.label, labelWidth); txt.SetPosition(GetLabelYPosition(totalWidth + gapWidth, i, yAxisIndex, yAxis)); - txt.SetText(labelName); yAxis.runtimeAxisLabelList.Add(txt); totalWidth += labelWidth; } @@ -693,14 +694,15 @@ namespace XCharts var labelWidth = AxisHelper.GetScaleWidth(xAxis, grid.runtimeWidth, i + 1, dataZoom); var inside = xAxis.axisLabel.inside; var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar); + var labelName = AxisHelper.GetLabelName(xAxis, grid.runtimeWidth, i, xAxis.runtimeMinValue, + xAxis.runtimeMaxValue, dataZoom, isPercentStack); var label = ChartHelper.AddAxisLabelObject(i, ChartCached.GetXAxisName(xAxisIndex, i), axisObj.transform, - new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f), new Vector2(textWidth, textHeight), xAxis, theme.axis); + new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f), new Vector2(textWidth, textHeight), + xAxis, theme.axis,labelName, true); if (i == 0) xAxis.axisLabel.SetRelatedText(label.label, labelWidth); label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleCenter)); label.SetPosition(GetLabelXPosition(totalWidth + textWidth / 2 + gapWidth, i, xAxisIndex, xAxis)); - label.SetText(AxisHelper.GetLabelName(xAxis, grid.runtimeWidth, i, xAxis.runtimeMinValue, xAxis.runtimeMaxValue, dataZoom, - isPercentStack)); xAxis.runtimeAxisLabelList.Add(label); totalWidth += labelWidth; } @@ -1286,7 +1288,7 @@ namespace XCharts } } - + protected void DrawXTooltipIndicator(VertexHelper vh) { diff --git a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs index 57b64a1f..341059f8 100644 --- a/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs +++ b/Assets/XCharts/Runtime/Internal/Object/ChartLabel.cs @@ -12,7 +12,6 @@ namespace XCharts { public class ChartLabel : ChartObject { - private bool m_EmptyStringHideIcon = false; private bool m_LabelAutoSize = true; private float m_LabelPaddingLeftRight = 3f; private float m_LabelPaddingTopBottom = 3f; @@ -49,8 +48,6 @@ namespace XCharts } } - public bool emptyStringHideIcon { set { m_EmptyStringHideIcon = value; } } - public ChartLabel() { } @@ -182,10 +179,6 @@ namespace XCharts return sizeChange; } AdjustIconPos(); - if (m_EmptyStringHideIcon) - { - ChartHelper.SetActive(m_IconImage.gameObject, !string.IsNullOrEmpty(text)); - } } return false; } diff --git a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs index 4dd596ee..e5edfeae 100644 --- a/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Utility/ChartHelper.cs @@ -400,12 +400,11 @@ namespace XCharts } public static ChartLabel AddAxisLabelObject(int index, string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, - Vector2 pivot, Vector2 sizeDelta, Axis axis, ComponentTheme theme) + Vector2 pivot, Vector2 sizeDelta, Axis axis, ComponentTheme theme, string content, bool autoHideWhenContentEmpty = false) { var textStyle = axis.axisLabel.textStyle; var iconStyle = axis.iconStyle; var label = new ChartLabel(); - label.emptyStringHideIcon = true; label.gameObject = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); // TODO: 为了兼容旧版本,这里后面版本可以去掉 @@ -414,11 +413,17 @@ namespace XCharts { GameObject.DestroyImmediate(oldText); } + var labelShow = axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0); + if (autoHideWhenContentEmpty && string.IsNullOrEmpty(content)) + { + labelShow &= false; + } label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme); label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, iconStyle.width, iconStyle.height); label.SetAutoSize(false); label.UpdateIcon(iconStyle, axis.GetIcon(index)); - label.label.SetActive(axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0)); + label.label.SetActive(labelShow); + label.SetText(content); return label; } diff --git a/Assets/XCharts/Runtime/PolarChart.cs b/Assets/XCharts/Runtime/PolarChart.cs index e3ef8beb..28d8b8a8 100644 --- a/Assets/XCharts/Runtime/PolarChart.cs +++ b/Assets/XCharts/Runtime/PolarChart.cs @@ -143,14 +143,15 @@ namespace XCharts * (tickWidth + axis.axisLabel.margin); for (int i = 0; i < splitNumber; i++) { - float labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null); - bool inside = axis.axisLabel.inside; - var label = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), - new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), axis, theme.axis); - if (i == 0) axis.axisLabel.SetRelatedText(label.label, labelWidth); + var labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null); + var inside = axis.axisLabel.inside; var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar); var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.runtimeMinValue, axis.runtimeMaxValue, null, isPercentStack); + var label = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), + new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), axis, theme.axis, + labelName); + if (i == 0) axis.axisLabel.SetRelatedText(label.label, labelWidth); label.label.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter)); label.SetText(labelName); var pos = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVetor; @@ -226,13 +227,12 @@ namespace XCharts { float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null); bool inside = axis.axisLabel.inside; - + var labelName = AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue, + null, isPercentStack); var label = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), - new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig), axis, theme.axis); - + new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig), axis, + theme.axis, labelName); label.label.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter)); - label.SetText(AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue, - null, isPercentStack)); var pos = ChartHelper.GetPos(cenPos, radius + margin, isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true); AxisHelper.AdjustCircleLabelPos(label, pos, cenPos, txtHig, Vector3.zero); diff --git a/Assets/XCharts/Runtime/XChartsMgr.cs b/Assets/XCharts/Runtime/XChartsMgr.cs index 713ed8f3..273200f8 100644 --- a/Assets/XCharts/Runtime/XChartsMgr.cs +++ b/Assets/XCharts/Runtime/XChartsMgr.cs @@ -33,8 +33,8 @@ namespace XCharts [ExecuteInEditMode] public class XChartsMgr : MonoBehaviour { - internal static string _version = "2.2.2"; - internal static int _versionDate = 20210618; + internal static string _version = "2.2.3"; + internal static int _versionDate = 20210620; public static string version { get { return _version; } } public static int versionDate { get { return _versionDate; } } public static string fullVersion { get { return version + "-" + versionDate; } } diff --git a/Assets/XCharts/package.json b/Assets/XCharts/package.json index 872a21d0..79360d58 100644 --- a/Assets/XCharts/package.json +++ b/Assets/XCharts/package.json @@ -1,9 +1,9 @@ { "name": "com.monitor1394.xcharts", "displayName": "XCharts", - "version": "2.2.2", - "date": "20210618", - "checkdate": "20210618", + "version": "2.2.3", + "date": "20210620", + "checkdate": "20210620", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "unity": "2018.3", "description": "A charting and data visualization library for Unity.", diff --git a/Assets/XCharts/version.json b/Assets/XCharts/version.json index 3144966e..5af132c2 100644 --- a/Assets/XCharts/version.json +++ b/Assets/XCharts/version.json @@ -1,7 +1,7 @@ { - "version": "2.2.2", - "date": "20210618", - "checkdate": "20210618", + "version": "2.2.3", + "date": "20210620", + "checkdate": "20210620", "desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!", "homepage": "https://github.com/monitor1394/unity-ugui-XCharts" } \ No newline at end of file