From 9c69774d355b560e10e562d125789bfa2b5f9ec3 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 11 Dec 2021 18:26:28 +0800 Subject: [PATCH] 3.0 - bar chart --- .../Editor/ChildComponents/AnimationDrawer.cs | 2 +- .../MainComponents/MainComponentBaseEditor.cs | 2 - Assets/XCharts/Editor/Series/BarEditor.cs | 30 ++- Assets/XCharts/Editor/Series/LineEditor.cs | 31 ++- Assets/XCharts/Editor/Series/PieEditor.cs | 14 +- .../XCharts/Editor/Series/SerieBaseEditor.cs | 41 ++- Assets/XCharts/Editor/Series/SerieEditor.cs | 11 + .../Editor/Utilities/ChartEditorHelper.cs | 6 +- .../Runtime/Component/Axis/AxisHelper.cs | 23 +- .../{SerieAnimation.cs => AnimationStyle.cs} | 12 +- ...imation.cs.meta => AnimationStyle.cs.meta} | 2 +- .../Runtime/Component/Legend/LegendHelper.cs | 10 +- .../Runtime/Component/Mark/MarkLine.cs | 4 +- .../Runtime/Component/Mark/MarkLineHandler.cs | 2 +- .../Component/Radar/RadarCoordHandler.cs | 45 ++-- .../Component/Tooltip/TooltipHandler.cs | 4 +- .../Component/Tooltip/TooltipHelper.cs | 2 +- .../Runtime/Helper/SerieLabelHelper.cs | 4 +- .../Runtime/Internal/BaseChart.Serie.cs | 2 +- Assets/XCharts/Runtime/Internal/BaseChart.cs | 9 +- .../XCharts/Runtime/Serie/Bar/BarHandler.cs | 253 +++++++++++------- .../Serie/Candlestick/CandlestickHandler.cs | 2 +- .../Runtime/Serie/Heatmap/HeatmapHandler.cs | 6 +- .../Serie/Line/LineHandler.GridCoord.cs | 9 +- .../Serie/Line/LineHandler.PolarCoord.cs | 6 +- .../XCharts/Runtime/Serie/Line/LineHelper.cs | 2 +- .../XCharts/Runtime/Serie/Pie/PieHandler.cs | 20 +- .../Runtime/Serie/Radar/RadarHandler.cs | 4 +- .../XCharts/Runtime/Serie/Ring/RingHandler.cs | 6 +- .../Serie/Scatter/BaseScatterHandler.cs | 14 +- Assets/XCharts/Runtime/Serie/Serie.cs | 12 +- Assets/XCharts/Runtime/Serie/SerieData.cs | 2 +- .../XCharts/Runtime/Serie/SerieDataContext.cs | 2 +- 33 files changed, 362 insertions(+), 232 deletions(-) rename Assets/XCharts/Runtime/Component/Child/{SerieAnimation.cs => AnimationStyle.cs} (99%) rename Assets/XCharts/Runtime/Component/Child/{SerieAnimation.cs.meta => AnimationStyle.cs.meta} (83%) diff --git a/Assets/XCharts/Editor/ChildComponents/AnimationDrawer.cs b/Assets/XCharts/Editor/ChildComponents/AnimationDrawer.cs index 58292562..d131a2b7 100644 --- a/Assets/XCharts/Editor/ChildComponents/AnimationDrawer.cs +++ b/Assets/XCharts/Editor/ChildComponents/AnimationDrawer.cs @@ -10,7 +10,7 @@ using UnityEngine; namespace XCharts { - [CustomPropertyDrawer(typeof(SerieAnimation), true)] + [CustomPropertyDrawer(typeof(AnimationStyle), true)] public class AnimationDrawer : BasePropertyDrawer { public override string ClassName { get { return "Animation"; } } diff --git a/Assets/XCharts/Editor/MainComponents/MainComponentBaseEditor.cs b/Assets/XCharts/Editor/MainComponents/MainComponentBaseEditor.cs index 9f6ce840..1e28b602 100644 --- a/Assets/XCharts/Editor/MainComponents/MainComponentBaseEditor.cs +++ b/Assets/XCharts/Editor/MainComponents/MainComponentBaseEditor.cs @@ -111,8 +111,6 @@ namespace XCharts protected void PropertyTwoFiled(string relativePropName) { - //TODO: - //PropertyField(relativePropName); var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f); var prop = FindProperty(relativePropName); ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName); diff --git a/Assets/XCharts/Editor/Series/BarEditor.cs b/Assets/XCharts/Editor/Series/BarEditor.cs index c353fd24..3f8e522d 100644 --- a/Assets/XCharts/Editor/Series/BarEditor.cs +++ b/Assets/XCharts/Editor/Series/BarEditor.cs @@ -22,21 +22,29 @@ namespace XCharts PropertyField("m_XAxisIndex"); PropertyField("m_YAxisIndex"); } - PropertyFieldLimitMin("m_MinShow", 0); - PropertyFieldLimitMin("m_MaxShow", 0); - PropertyFieldLimitMin("m_MaxCache", 0); PropertyField("m_BarType"); PropertyField("m_BarPercentStack"); PropertyField("m_BarWidth"); PropertyField("m_BarGap"); - PropertyField("m_BarZebraWidth"); - PropertyField("m_BarZebraGap"); - PropertyField("m_Clip"); - PropertyField("m_Ignore"); - PropertyField("m_IgnoreValue"); - PropertyField("m_ShowAsPositiveNumber"); - PropertyField("m_Large"); - PropertyField("m_LargeThreshold"); + if (serie.barType == BarType.Zebra) + { + PropertyField("m_BarZebraWidth"); + PropertyField("m_BarZebraGap"); + } + + PropertyFiledMore(() => + { + PropertyFieldLimitMin("m_MinShow", 0); + PropertyFieldLimitMin("m_MaxShow", 0); + PropertyFieldLimitMin("m_MaxCache", 0); + PropertyField("m_Ignore"); + PropertyField("m_IgnoreValue"); + PropertyField("m_IgnoreLineBreak"); + PropertyField("m_ShowAsPositiveNumber"); + PropertyField("m_Large"); + PropertyField("m_LargeThreshold"); + PropertyField("m_Clip"); + }); PropertyField("m_ItemStyle"); PropertyField("m_IconStyle"); diff --git a/Assets/XCharts/Editor/Series/LineEditor.cs b/Assets/XCharts/Editor/Series/LineEditor.cs index 101c6451..d786c385 100644 --- a/Assets/XCharts/Editor/Series/LineEditor.cs +++ b/Assets/XCharts/Editor/Series/LineEditor.cs @@ -5,6 +5,8 @@ /* */ /************************************************/ +using UnityEngine; + namespace XCharts { [SerieEditor(typeof(Line))] @@ -22,20 +24,23 @@ namespace XCharts PropertyField("m_XAxisIndex"); PropertyField("m_YAxisIndex"); } - PropertyFieldLimitMin("m_MinShow", 0); - PropertyFieldLimitMin("m_MaxShow", 0); - PropertyFieldLimitMin("m_MaxCache", 0); PropertyField("m_LineType"); - PropertyField("m_SampleDist"); - PropertyField("m_SampleType"); - PropertyField("m_SampleAverage"); - PropertyField("m_Clip"); - PropertyField("m_Ignore"); - PropertyField("m_IgnoreValue"); - PropertyField("m_IgnoreLineBreak"); - PropertyField("m_ShowAsPositiveNumber"); - PropertyField("m_Large"); - PropertyField("m_LargeThreshold"); + PropertyFiledMore(() => + { + PropertyFieldLimitMin("m_MinShow", 0); + PropertyFieldLimitMin("m_MaxShow", 0); + PropertyFieldLimitMin("m_MaxCache", 0); + PropertyField("m_SampleDist"); + PropertyField("m_SampleType"); + PropertyField("m_SampleAverage"); + PropertyField("m_Ignore"); + PropertyField("m_IgnoreValue"); + PropertyField("m_IgnoreLineBreak"); + PropertyField("m_ShowAsPositiveNumber"); + PropertyField("m_Large"); + PropertyField("m_LargeThreshold"); + PropertyField("m_Clip"); + }); PropertyField("m_Symbol"); PropertyField("m_LineStyle"); PropertyField("m_LineArrow"); diff --git a/Assets/XCharts/Editor/Series/PieEditor.cs b/Assets/XCharts/Editor/Series/PieEditor.cs index c6ff2fbb..db3e4080 100644 --- a/Assets/XCharts/Editor/Series/PieEditor.cs +++ b/Assets/XCharts/Editor/Series/PieEditor.cs @@ -16,11 +16,15 @@ namespace XCharts PropertyField("m_Space"); PropertyTwoFiled("m_Center"); PropertyTwoFiled("m_Radius"); - PropertyField("m_MinAngle"); - PropertyField("m_RoundCap"); - PropertyField("m_Ignore"); - PropertyField("m_IgnoreValue"); - PropertyField("m_AvoidLabelOverlap"); + + PropertyFiledMore(() => + { + PropertyField("m_MinAngle"); + PropertyField("m_RoundCap"); + PropertyField("m_Ignore"); + PropertyField("m_IgnoreValue"); + PropertyField("m_AvoidLabelOverlap"); + }); PropertyField("m_ItemStyle"); PropertyField("m_IconStyle"); diff --git a/Assets/XCharts/Editor/Series/SerieBaseEditor.cs b/Assets/XCharts/Editor/Series/SerieBaseEditor.cs index 99d3cf07..e8ab263d 100644 --- a/Assets/XCharts/Editor/Series/SerieBaseEditor.cs +++ b/Assets/XCharts/Editor/Series/SerieBaseEditor.cs @@ -97,13 +97,14 @@ namespace XCharts return baseProperty.FindPropertyRelative(path); } - protected void PropertyField(string path) + protected SerializedProperty PropertyField(string path) { Assert.IsNotNull(path); var property = FindProperty(path); Assert.IsNotNull(property, "Can't find:" + path); var title = ChartEditorHelper.GetContent(property.displayName); PropertyField(property, title); + return property; } protected void PropertyField(SerializedProperty property) @@ -126,18 +127,40 @@ namespace XCharts protected void PropertyTwoFiled(string relativePropName) { - //TODO: - PropertyField(relativePropName); + var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f); + var prop = FindProperty(relativePropName); + ChartEditorHelper.MakeTwoField(ref m_DrawRect, m_DrawRect.width, prop, prop.displayName); } - protected void PropertyFieldLimitMin(string relativePropName, double value) + protected void PropertyFieldLimitMin(string relativePropName, double min) { - //TODO: - PropertyField(relativePropName); + var prop = PropertyField(relativePropName); + switch (prop.propertyType) + { + case SerializedPropertyType.Float: + if (prop.floatValue < min) + prop.floatValue = (float)min; + break; + case SerializedPropertyType.Integer: + if (prop.intValue < min) + prop.intValue = (int)min; + break; + } + } - protected void PropertyFieldLimitMax(string relativePropName, double value) + protected void PropertyFieldLimitMax(string relativePropName, int max) { - //TODO: - PropertyField(relativePropName); + var prop = PropertyField(relativePropName); + switch (prop.propertyType) + { + case SerializedPropertyType.Float: + if (prop.floatValue > max) + prop.floatValue = (float)max; + break; + case SerializedPropertyType.Integer: + if (prop.intValue > max) + prop.intValue = (int)max; + break; + } } } } \ No newline at end of file diff --git a/Assets/XCharts/Editor/Series/SerieEditor.cs b/Assets/XCharts/Editor/Series/SerieEditor.cs index c8018a63..ad1ed0db 100644 --- a/Assets/XCharts/Editor/Series/SerieEditor.cs +++ b/Assets/XCharts/Editor/Series/SerieEditor.cs @@ -13,6 +13,8 @@ namespace XCharts { public class SerieEditor : SerieBaseEditor where T : Serie { + protected const string MORE = "More"; + protected bool m_MoreFoldout = false; private bool m_DataFoldout = false; private bool m_DataComponentFoldout = true; private Dictionary m_DataElementFoldout = new Dictionary(); @@ -90,6 +92,15 @@ namespace XCharts EditorGUI.indentLevel--; } + protected void PropertyFiledMore(System.Action action) + { + m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null); + if (m_MoreFoldout) + { + if (action != null) action(); + } + } + private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName) { bool flag; diff --git a/Assets/XCharts/Editor/Utilities/ChartEditorHelper.cs b/Assets/XCharts/Editor/Utilities/ChartEditorHelper.cs index 0ae5b487..8fe4501f 100644 --- a/Assets/XCharts/Editor/Utilities/ChartEditorHelper.cs +++ b/Assets/XCharts/Editor/Utilities/ChartEditorHelper.cs @@ -103,11 +103,11 @@ namespace XCharts { EditorGUI.LabelField(drawRect, name); var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; - var diff = 14 + EditorGUI.indentLevel * 14; + var diff = 13 + EditorGUI.indentLevel * 14; var offset = diff - INDENT_WIDTH; var tempWidth = (rectWidth - startX + diff) / 2; - var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height); - var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth, drawRect.height); + 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); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; diff --git a/Assets/XCharts/Runtime/Component/Axis/AxisHelper.cs b/Assets/XCharts/Runtime/Component/Axis/AxisHelper.cs index e7620ebc..a395f127 100644 --- a/Assets/XCharts/Runtime/Component/Axis/AxisHelper.cs +++ b/Assets/XCharts/Runtime/Component/Axis/AxisHelper.cs @@ -480,6 +480,16 @@ namespace XCharts } public static float GetAxisPosition(GridCoord grid, Axis axis, float scaleWidth, double value) + { + return GetAxisPositionInternal(grid, axis, scaleWidth, value, true); + } + + public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value) + { + return GetAxisPositionInternal(grid, axis, scaleWidth, value, false); + } + + private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY) { var isY = axis is YAxis; var gridHeight = isY ? grid.context.height : grid.context.width; @@ -489,19 +499,24 @@ namespace XCharts { int minIndex = axis.GetLogMinIndex(); float nowIndex = axis.GetLogValue(value); - return gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight; + return includeGridXY + ? gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight + : (nowIndex - minIndex) / axis.splitNumber * gridHeight; } else if (axis.IsCategory()) { var categoryIndex = (int)value; - var categoryStart = gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0); - return categoryStart + scaleWidth * categoryIndex; + return includeGridXY + ? gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex + : (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex; } else { var yDataHig = (axis.context.minMaxRange == 0) ? 0f : (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight); - return gridXY + yDataHig; + return includeGridXY + ? gridXY + yDataHig + : yDataHig; } } } diff --git a/Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs b/Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs similarity index 99% rename from Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs rename to Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs index 5d9eba0c..e253d147 100644 --- a/Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs +++ b/Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs @@ -14,12 +14,22 @@ namespace XCharts public delegate float CustomAnimationDelay(int dataIndex); public delegate float CustomAnimationDuration(int dataIndex); + + public enum AnimationType + { + Default, + LeftToRight, + BottomToTop, + InsideOut, + Clockwise, + + } /// /// the animation of serie. /// 动画表现。 /// [System.Serializable] - public class SerieAnimation : ChildComponent + public class AnimationStyle : ChildComponent { public enum Easing { diff --git a/Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs.meta b/Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs.meta similarity index 83% rename from Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs.meta rename to Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs.meta index 2fc4ce85..8bf3ddad 100644 --- a/Assets/XCharts/Runtime/Component/Child/SerieAnimation.cs.meta +++ b/Assets/XCharts/Runtime/Component/Child/AnimationStyle.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c6560100f155244fba80a175e6a28139 +guid: d51f91843500c4092909a6779592b654 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/XCharts/Runtime/Component/Legend/LegendHelper.cs b/Assets/XCharts/Runtime/Component/Legend/LegendHelper.cs index d8368c12..46ace612 100644 --- a/Assets/XCharts/Runtime/Component/Legend/LegendHelper.cs +++ b/Assets/XCharts/Runtime/Component/Legend/LegendHelper.cs @@ -242,7 +242,7 @@ namespace XCharts if (legendName.Equals(serie.serieName)) { serie.show = show; - serie.highlighted = false; + serie.highlight = false; if (serie.show) needShow = true; } else @@ -252,7 +252,7 @@ namespace XCharts if (legendName.Equals(data.name)) { data.show = show; - data.context.highlighted = false; + data.context.highlight = false; if (data.show) needShow = true; } } @@ -268,7 +268,7 @@ namespace XCharts { if (legendName.Equals(serie.serieName)) { - serie.highlighted = heighlight; + serie.highlight = heighlight; } else { @@ -276,8 +276,8 @@ namespace XCharts { if (legendName.Equals(data.name)) { - data.context.highlighted = heighlight; - if (data.context.highlighted) show = true; + data.context.highlight = heighlight; + if (data.context.highlight) show = true; } } } diff --git a/Assets/XCharts/Runtime/Component/Mark/MarkLine.cs b/Assets/XCharts/Runtime/Component/Mark/MarkLine.cs index 47b89a3e..5705111e 100644 --- a/Assets/XCharts/Runtime/Component/Mark/MarkLine.cs +++ b/Assets/XCharts/Runtime/Component/Mark/MarkLine.cs @@ -45,7 +45,7 @@ namespace XCharts { [SerializeField] private bool m_Show = true; [SerializeField] private int m_SerieIndex = 0; - [SerializeField] private SerieAnimation m_Animation = new SerieAnimation(); + [SerializeField] private AnimationStyle m_Animation = new AnimationStyle(); [SerializeField] private List m_Data = new List(); /// @@ -66,7 +66,7 @@ namespace XCharts /// The animation of markline. /// 标线的动画样式。 /// - public SerieAnimation animation + public AnimationStyle animation { get { return m_Animation; } set { if (PropertyUtil.SetClass(ref m_Animation, value)) SetVerticesDirty(); } diff --git a/Assets/XCharts/Runtime/Component/Mark/MarkLineHandler.cs b/Assets/XCharts/Runtime/Component/Mark/MarkLineHandler.cs index 9872f0c5..12ac5c41 100644 --- a/Assets/XCharts/Runtime/Component/Mark/MarkLineHandler.cs +++ b/Assets/XCharts/Runtime/Component/Mark/MarkLineHandler.cs @@ -222,7 +222,7 @@ namespace XCharts } } - private void DrawMakLineData(VertexHelper vh, MarkLineData data, SerieAnimation animation, Serie serie, + private void DrawMakLineData(VertexHelper vh, MarkLineData data, AnimationStyle animation, Serie serie, GridCoord grid, Color32 serieColor, Vector3 sp, Vector3 ep) { if (!animation.IsFinish()) diff --git a/Assets/XCharts/Runtime/Component/Radar/RadarCoordHandler.cs b/Assets/XCharts/Runtime/Component/Radar/RadarCoordHandler.cs index 00317e4f..f8380264 100644 --- a/Assets/XCharts/Runtime/Component/Radar/RadarCoordHandler.cs +++ b/Assets/XCharts/Runtime/Component/Radar/RadarCoordHandler.cs @@ -85,10 +85,6 @@ namespace XCharts private void DrawCricleRadar(VertexHelper vh, RadarCoord radar) { - if (!radar.splitLine.show && !radar.splitArea.show) - { - return; - } float insideRadius = 0, outsideRadius = 0; float block = radar.context.radius / radar.splitNumber; int indicatorNum = radar.indicatorList.Count; @@ -96,7 +92,10 @@ namespace XCharts Vector3 p1; float angle = 2 * Mathf.PI / indicatorNum; var lineColor = radar.axisLine.GetColor(chart.theme.axis.lineColor); - var lineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth); + var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth); + var lineType = radar.axisLine.GetType(chart.theme.axis.lineType); + var splitLineColor = radar.splitLine.GetColor(chart.theme.axis.splitLineColor); + var splitLineWidth = radar.splitLine.GetWidth(chart.theme.axis.splitLineWidth); for (int i = 0; i < radar.splitNumber; i++) { var color = radar.splitArea.GetColor(i, chart.theme.axis); @@ -108,29 +107,25 @@ namespace XCharts } if (radar.splitLine.show) { - UGL.DrawEmptyCricle(vh, p, outsideRadius, lineWidth, lineColor, + UGL.DrawEmptyCricle(vh, p, outsideRadius, splitLineWidth, splitLineColor, Color.clear, chart.settings.cicleSmoothness); } insideRadius = outsideRadius; } - for (int j = 0; j <= indicatorNum; j++) + if (radar.axisLine.show) { - float currAngle = j * angle; - p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), - p.y + outsideRadius * Mathf.Cos(currAngle)); - if (radar.splitLine.show) + for (int j = 0; j <= indicatorNum; j++) { - UGL.DrawLine(vh, p, p1, lineWidth / 2, lineColor); + float currAngle = j * angle; + p1 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), + p.y + outsideRadius * Mathf.Cos(currAngle)); + ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p1, lineColor); } } } private void DrawPolygonRadar(VertexHelper vh, RadarCoord radar) { - if (!radar.splitLine.show && !radar.splitArea.show) - { - return; - } float insideRadius = 0, outsideRadius = 0; float block = radar.context.radius / radar.splitNumber; int indicatorNum = radar.indicatorList.Count; @@ -145,7 +140,6 @@ namespace XCharts var splitLineType = radar.splitLine.GetType(chart.theme.axis.splitLineType); for (int i = 0; i < radar.splitNumber; i++) { - var isLast = i == radar.splitNumber - 1; var color = radar.splitArea.GetColor(i, chart.theme.axis); outsideRadius = insideRadius + block; p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0)); @@ -163,24 +157,21 @@ namespace XCharts } if (radar.splitLine.NeedShow(i)) { - if (isLast) - ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor); - else - ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor); + ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor); } p1 = p4; p2 = p3; } insideRadius = outsideRadius; } - for (int j = 0; j <= indicatorNum; j++) + if (radar.axisLine.show) { - float currAngle = j * angle; - p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), - p.y + outsideRadius * Mathf.Cos(currAngle)); - if (radar.splitLine.show) + for (int j = 0; j <= indicatorNum; j++) { - ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p, p3, splitLineColor); + float currAngle = j * angle; + p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), + p.y + outsideRadius * Mathf.Cos(currAngle)); + ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor); } } } diff --git a/Assets/XCharts/Runtime/Component/Tooltip/TooltipHandler.cs b/Assets/XCharts/Runtime/Component/Tooltip/TooltipHandler.cs index 3506b4de..68f778a0 100644 --- a/Assets/XCharts/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Assets/XCharts/Runtime/Component/Tooltip/TooltipHandler.cs @@ -291,11 +291,11 @@ namespace XCharts if (System.Math.Abs(dist) <= symbolSize) { serie.context.pointerAxisDataIndexs.Add(i); - serieData.context.highlighted = true; + serieData.context.highlight = true; } else { - serieData.context.highlighted = false; + serieData.context.highlight = false; } } } diff --git a/Assets/XCharts/Runtime/Component/Tooltip/TooltipHelper.cs b/Assets/XCharts/Runtime/Component/Tooltip/TooltipHelper.cs index 0587457d..4eacf59a 100644 --- a/Assets/XCharts/Runtime/Component/Tooltip/TooltipHelper.cs +++ b/Assets/XCharts/Runtime/Component/Tooltip/TooltipHelper.cs @@ -110,7 +110,7 @@ namespace XCharts var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); if (isCartesian) { - if (serieData != null && serieData.context.highlighted) + if (serieData != null && serieData.context.highlight) { sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : ""); sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",") diff --git a/Assets/XCharts/Runtime/Helper/SerieLabelHelper.cs b/Assets/XCharts/Runtime/Helper/SerieLabelHelper.cs index 0ee88aa4..11bea376 100644 --- a/Assets/XCharts/Runtime/Helper/SerieLabelHelper.cs +++ b/Assets/XCharts/Runtime/Helper/SerieLabelHelper.cs @@ -125,7 +125,7 @@ namespace XCharts for (int i = 0; i < serie.dataCount; i++) { var serieData = serie.data[i]; - var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlighted); + var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight); if (serieLabel.show && serieData.labelObject != null) { if (!serie.show || !serieData.show) @@ -160,7 +160,7 @@ namespace XCharts { var serieData = serie.GetSerieData(0); if (serieData == null) return; - var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlighted); + var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.context.highlight); if (serieLabel.show && serieData.labelObject != null) { if (!serie.show || !serieData.show) diff --git a/Assets/XCharts/Runtime/Internal/BaseChart.Serie.cs b/Assets/XCharts/Runtime/Internal/BaseChart.Serie.cs index 77f73f76..30ae5b9c 100644 --- a/Assets/XCharts/Runtime/Internal/BaseChart.Serie.cs +++ b/Assets/XCharts/Runtime/Internal/BaseChart.Serie.cs @@ -749,7 +749,7 @@ namespace XCharts for (int i = 0; i < m_Series.Count; i++) { var serie = m_Series[i]; - if (serie is T) continue; + if (!(serie is T)) continue; if (string.IsNullOrEmpty(serie.stack)) { if (serie.index == currSerie.index) return index; diff --git a/Assets/XCharts/Runtime/Internal/BaseChart.cs b/Assets/XCharts/Runtime/Internal/BaseChart.cs index 2ba9b74c..c6c3f4a6 100644 --- a/Assets/XCharts/Runtime/Internal/BaseChart.cs +++ b/Assets/XCharts/Runtime/Internal/BaseChart.cs @@ -523,7 +523,7 @@ namespace XCharts { if (legendName.Equals(serie.serieName)) { - serie.highlighted = true; + serie.highlight = true; RefreshPainter(serie); } } @@ -541,7 +541,7 @@ namespace XCharts { if (legendName.Equals(serie.serieName)) { - serie.highlighted = false; + serie.highlight = false; RefreshPainter(serie); } } @@ -573,12 +573,13 @@ namespace XCharts for (int i = painter.index * rate; i < (painter.index + 1) * rate && i < maxSeries; i++) { var serie = m_Series[i]; + serie.context.colorIndex = GetLegendRealShowNameIndex(serie.legendName); + serie.context.dataPoints.Clear(); + serie.context.dataIgnore.Clear(); if (m_OnCustomDrawSerieBeforeCallback != null) { m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie); } - serie.context.dataPoints.Clear(); - serie.context.dataIgnore.Clear(); DrawPainterSerie(vh, serie); if (i >= 0 && i < m_SerieHandlers.Count) { diff --git a/Assets/XCharts/Runtime/Serie/Bar/BarHandler.cs b/Assets/XCharts/Runtime/Serie/Bar/BarHandler.cs index a549091b..4194c381 100644 --- a/Assets/XCharts/Runtime/Serie/Bar/BarHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Bar/BarHandler.cs @@ -67,11 +67,7 @@ namespace XCharts public override void DrawSerie(VertexHelper vh) { - var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName); - var yCategory = ComponentHelper.IsAnyCategoryOfYAxis(chart.components); - serie.context.dataPoints.Clear(); - if (yCategory) DrawYBarSerie(vh, serie, colorIndex); - else DrawXBarSerie(vh, serie, colorIndex); + DrawXBarSerie(vh, serie, serie.context.colorIndex); } private void UpdateSerieContext() @@ -85,12 +81,12 @@ namespace XCharts { serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerEnter = true; - serieData.context.highlighted = true; + serieData.context.highlight = true; chart.RefreshTopPainter(); } else { - serieData.context.highlighted = false; + serieData.context.highlight = false; } } } @@ -137,8 +133,8 @@ namespace XCharts serie.context.dataPoints.Add(Vector3.zero); continue; } - var highlight = serie.data[i].context.highlighted - || serie.highlighted; + var highlight = serie.data[i].context.highlight + || serie.highlight; var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); serieData.context.canShowLabel = true; @@ -242,21 +238,51 @@ namespace XCharts private void DrawXBarSerie(VertexHelper vh, Bar serie, int colorIndex) { - if (!serie.show) return; - if (serie.animation.HasFadeOut()) return; - var yAxis = chart.GetChartComponent(serie.yAxisIndex); - var xAxis = chart.GetChartComponent(serie.xAxisIndex); - var grid = chart.GetChartComponent(xAxis.gridIndex); - var dataZoom = chart.GetDataZoomOfAxis(xAxis); + if (!serie.show || serie.animation.HasFadeOut()) + return; + + var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components); + + Axis axis; + Axis relativedAxis; + GridCoord grid; + + if (isY) + { + axis = chart.GetChartComponent(serie.yAxisIndex); + relativedAxis = chart.GetChartComponent(serie.xAxisIndex); + } + else + { + axis = chart.GetChartComponent(serie.xAxisIndex); + relativedAxis = chart.GetChartComponent(serie.yAxisIndex); + } + grid = chart.GetChartComponent(axis.gridIndex); + + if (axis == null) + return; + if (relativedAxis == null) + return; + if (grid == null) + return; + + var dataZoom = chart.GetDataZoomOfAxis(axis); var showData = serie.GetDataList(dataZoom); + + if (showData.Count <= 0) + return; + + var axisLength = isY ? grid.context.height : grid.context.width; + var isStack = SeriesHelper.IsStack(chart.series, serie.stack); - m_StackSerieData.Clear(); - if (isStack) SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData); - float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom); + if (isStack) + SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData); + + float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom); float barGap = chart.GetSerieBarGap(); float totalBarWidth = chart.GetSerieTotalWidth(categoryWidth, barGap); float barWidth = serie.GetBarWidth(categoryWidth); - float offset = (categoryWidth - totalBarWidth) / 2; + float offset = (categoryWidth - totalBarWidth) * 0.5f; float barGapWidth = barWidth + barWidth * barGap; float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack(serie) * barGapWidth; int maxCount = serie.maxShow > 0 @@ -266,10 +292,8 @@ namespace XCharts var isPercentStack = SeriesHelper.IsPercentStack(chart.series, serie.stack); bool dataChanging = false; float dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); - double xMinValue = xAxis.context.minValue; - double xMaxValue = xAxis.context.maxValue; - double yMinValue = yAxis.context.minValue; - double yMaxValue = yAxis.context.maxValue; + double yMinValue = relativedAxis.context.minValue; + double yMaxValue = relativedAxis.context.maxValue; var isAllBarEnd = true; serie.containerIndex = grid.index; serie.containterInstanceId = grid.instanceId; @@ -281,88 +305,40 @@ namespace XCharts serie.context.dataPoints.Add(Vector3.zero); continue; } - var highlight = serie.data[i].context.highlighted - || serie.highlighted; + if (serieData.IsDataChanged()) + dataChanging = true; + + var highlight = serieData.context.highlight || serie.highlight; var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); - double value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); - float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth; - if (serieData.IsDataChanged()) dataChanging = true; - float pX = grid.context.x + i * categoryWidth; - if (xAxis.IsValue() || xAxis.IsTime()) - { - space = 0; - if ((xMaxValue - xMinValue) <= 0) pX = grid.context.x; - else pX = grid.context.x + (float)((serieData.GetData(0) - xMinValue) / (xMaxValue - xMinValue)) * (grid.context.width - barWidth); - //if (xAxis.boundaryGap) pX += barWidth / 2; - } - else - { - if (!xAxis.boundaryGap) pX -= categoryWidth / 2; - } - float zeroY = grid.context.y + yAxis.context.offset; - float axisLineWidth = value == 0 ? 0 : - ((value < 0 ? -1 : 1) * xAxis.axisLine.GetWidth(chart.theme.axis.lineWidth)); - float pY = zeroY + axisLineWidth; - if (isStack) - { - for (int n = 0; n < m_StackSerieData.Count - 1; n++) - { - pY += m_StackSerieData[n][i].context.stackHeight; - } - } + var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse); + var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue); + var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth; + + var pX = 0f; + var pY = 0f; + UpdateXYPosition(grid, isY, axis, relativedAxis, i, categoryWidth, barWidth, isStack, value, ref pX, ref pY); var barHig = 0f; - double valueTotal = 0f; if (isPercentStack) { - valueTotal = chart.GetSerieSameStackTotalValue(serie.stack, i); - barHig = valueTotal != 0 ? (float)(value / valueTotal * grid.context.height) : 0; + var valueTotal = chart.GetSerieSameStackTotalValue(serie.stack, i); + barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * axisLength) : 0; } else { - valueTotal = (double)(yMaxValue - yMinValue); - if (valueTotal != 0) - { - if (yAxis.IsLog()) - { - int minIndex = yAxis.GetLogMinIndex(); - var nowIndex = yAxis.GetLogValue(value); - barHig = (nowIndex - minIndex) / yAxis.splitNumber * grid.context.height; - } - else - { - barHig = (float)((yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.context.height); - } - } + barHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, categoryWidth, relativedValue); } - serieData.context.stackHeight = barHig; + var isBarEnd = false; float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd); - if (!isBarEnd) isAllBarEnd = false; + if (!isBarEnd) + isAllBarEnd = false; + Vector3 plb, plt, prt, prb, top; - if (value < 0) - { - plb = new Vector3(pX + space + borderWidth, pY - borderWidth); - plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth); - prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth); - prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth); - } - else - { - plb = new Vector3(pX + space + borderWidth, pY + borderWidth); - plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth); - prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth); - prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth); - } - top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth); - if (serie.clip) - { - plb = chart.ClampInGrid(grid, plb); - plt = chart.ClampInGrid(grid, plt); - prt = chart.ClampInGrid(grid, prt); - prb = chart.ClampInGrid(grid, prb); - top = chart.ClampInGrid(grid, top); - } + UpdateRectPosition(grid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig, + out plb, out plt, out prt, out prb, out top); + serieData.context.stackHeight = barHig; + serieData.context.position = top; serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y); serie.context.dataPoints.Add(top); if (serie.show && currHig != 0) @@ -394,6 +370,97 @@ namespace XCharts } } + private void UpdateXYPosition(GridCoord grid, bool isY, Axis axis, Axis relativedAxis, int i, float categoryWidth, float barWidth, bool isStack, + double value, ref float pX, ref float pY) + { + if (isY) + { + if (axis.IsCategory()) + { + pY = grid.context.y + i * categoryWidth + (axis.boundaryGap ? 0 : -categoryWidth * 0.5f); + } + else + { + if (axis.context.minMaxRange <= 0) pY = grid.context.y; + else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth); + } + pX = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0); + if (isStack) + { + for (int n = 0; n < m_StackSerieData.Count - 1; n++) + pX += m_StackSerieData[n][i].context.stackHeight; + } + } + else + { + if (axis.IsCategory()) + { + pX = grid.context.x + i * categoryWidth + (axis.boundaryGap ? 0 : -categoryWidth * 0.5f); + } + else + { + if (axis.context.minMaxRange <= 0) pX = grid.context.x; + else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth); + } + pY = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0); + if (isStack) + { + for (int n = 0; n < m_StackSerieData.Count - 1; n++) + pY += m_StackSerieData[n][i].context.stackHeight; + } + } + } + + private void UpdateRectPosition(GridCoord grid, bool isY, double yValue, float pX, float pY, float space, float borderWidth, + float barWidth, float currHig, + out Vector3 plb, out Vector3 plt, out Vector3 prt, out Vector3 prb, out Vector3 top) + { + if (isY) + { + if (yValue < 0) + { + plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth); + prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth); + prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth); + plb = new Vector3(pX - borderWidth, pY + space + borderWidth); + } + else + { + plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth); + prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth); + prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth); + plb = new Vector3(pX + borderWidth, pY + space + borderWidth); + } + top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2); + } + else + { + if (yValue < 0) + { + plb = new Vector3(pX + space + borderWidth, pY - borderWidth); + plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth); + prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth); + prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth); + } + else + { + plb = new Vector3(pX + space + borderWidth, pY + borderWidth); + plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth); + prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth); + prb = new Vector3(pX + space + barWidth - borderWidth, pY + borderWidth); + } + top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth); + } + if (serie.clip) + { + plb = chart.ClampInGrid(grid, plb); + plt = chart.ClampInGrid(grid, plt); + prt = chart.ClampInGrid(grid, prt); + prb = chart.ClampInGrid(grid, prb); + top = chart.ClampInGrid(grid, top); + } + } + private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex, bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt, Vector3 prb, bool isYAxis, GridCoord grid) diff --git a/Assets/XCharts/Runtime/Serie/Candlestick/CandlestickHandler.cs b/Assets/XCharts/Runtime/Serie/Candlestick/CandlestickHandler.cs index e4d121cf..c6e3a243 100644 --- a/Assets/XCharts/Runtime/Serie/Candlestick/CandlestickHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Candlestick/CandlestickHandler.cs @@ -56,7 +56,7 @@ namespace XCharts serie.context.dataPoints.Add(Vector3.zero); continue; } - var highlight = serie.data[i].context.highlighted || serie.highlighted; + var highlight = serie.data[i].context.highlight || serie.highlight; var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight); var open = serieData.GetCurrData(0, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue); diff --git a/Assets/XCharts/Runtime/Serie/Heatmap/HeatmapHandler.cs b/Assets/XCharts/Runtime/Serie/Heatmap/HeatmapHandler.cs index edc9405c..a29e521f 100644 --- a/Assets/XCharts/Runtime/Serie/Heatmap/HeatmapHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Heatmap/HeatmapHandler.cs @@ -44,12 +44,12 @@ namespace XCharts { serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerEnter = true; - serieData.context.highlighted = true; + serieData.context.highlight = true; chart.RefreshTopPainter(); } else { - serieData.context.highlighted = false; + serieData.context.highlight = false; } } } @@ -122,7 +122,7 @@ namespace XCharts color = visualMap.GetColor(value); if (animationIndex >= 0 && i > animationIndex) continue; serieData.context.canShowLabel = true; - var emphasis = (serieData.context.highlighted) + var emphasis = (serieData.context.highlight) || visualMap.context.pointerIndex > 0; UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color); diff --git a/Assets/XCharts/Runtime/Serie/Line/LineHandler.GridCoord.cs b/Assets/XCharts/Runtime/Serie/Line/LineHandler.GridCoord.cs index 53ee6927..88824f23 100644 --- a/Assets/XCharts/Runtime/Serie/Line/LineHandler.GridCoord.cs +++ b/Assets/XCharts/Runtime/Serie/Line/LineHandler.GridCoord.cs @@ -93,9 +93,6 @@ namespace XCharts public override void DrawSerie(VertexHelper vh) { - var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName); - serie.context.colorIndex = colorIndex; - if (serie.IsUseCoord()) { DrawPolarLine(vh, serie); @@ -145,12 +142,12 @@ namespace XCharts { serie.context.pointerItemDataIndex = serieData.index; serie.context.pointerEnter = true; - serieData.context.highlighted = true; + serieData.context.highlight = true; chart.RefreshTopPainter(); } else { - serieData.context.highlighted = false; + serieData.context.highlight = false; } } } @@ -196,7 +193,7 @@ namespace XCharts if (ChartHelper.IsIngore(serie.context.dataPoints[i])) continue; - var highlight = serie.data[i].context.highlighted || serie.highlighted; + var highlight = serie.data[i].context.highlight || serie.highlight; var symbolSize = highlight ? symbol.GetSelectedSize(serie.data[i].data, theme.serie.lineSymbolSelectedSize) : symbol.GetSize(serie.data[i].data, theme.serie.lineSymbolSize); diff --git a/Assets/XCharts/Runtime/Serie/Line/LineHandler.PolarCoord.cs b/Assets/XCharts/Runtime/Serie/Line/LineHandler.PolarCoord.cs index b2d4ec4e..2ded4308 100644 --- a/Assets/XCharts/Runtime/Serie/Line/LineHandler.PolarCoord.cs +++ b/Assets/XCharts/Runtime/Serie/Line/LineHandler.PolarCoord.cs @@ -39,7 +39,7 @@ namespace XCharts var firstSerieData = datas[0]; var startPos = GetPolarPos(m_Polar, m_AngleAxis, firstSerieData, min, max, radius); var nextPos = Vector3.zero; - var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serie.index, serie.highlighted); + var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serie.index, serie.highlight); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); var currDetailProgress = 0f; var totalDetailProgress = datas.Count; @@ -86,9 +86,9 @@ namespace XCharts if (ChartHelper.IsIngore(serieData.context.position)) continue; - bool highlight = serieData.context.highlighted || serie.highlighted; + bool highlight = serieData.context.highlight || serie.highlight; if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) - && !serieData.context.highlighted) + && !serieData.context.highlight) continue; var symbolSize = highlight diff --git a/Assets/XCharts/Runtime/Serie/Line/LineHelper.cs b/Assets/XCharts/Runtime/Serie/Line/LineHelper.cs index 8fe34d76..179ec833 100644 --- a/Assets/XCharts/Runtime/Serie/Line/LineHelper.cs +++ b/Assets/XCharts/Runtime/Serie/Line/LineHelper.cs @@ -252,7 +252,7 @@ namespace XCharts var isVisualMapGradient = VisualMapHelper.IsNeedGradient(visualMap); var isLineStyleGradient = serie.lineStyle.IsNeedGradient(); - var highlight = serie.highlighted || serie.context.pointerEnter; + var highlight = serie.highlight || serie.context.pointerEnter; var lineWidth = serie.lineStyle.GetWidth(theme.serie.lineWidth); var lineColor = SerieHelper.GetLineColor(serie, theme, serie.context.colorIndex, highlight); diff --git a/Assets/XCharts/Runtime/Serie/Pie/PieHandler.cs b/Assets/XCharts/Runtime/Serie/Pie/PieHandler.cs index 36da4038..1101bd85 100644 --- a/Assets/XCharts/Runtime/Serie/Pie/PieHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Pie/PieHandler.cs @@ -133,16 +133,16 @@ namespace XCharts if (dataIndex >= 0) { if (lastDataIndex >= 0) - serie.GetSerieData(lastDataIndex).context.highlighted = false; + serie.GetSerieData(lastDataIndex).context.highlight = false; if (lastDataIndex != dataIndex) chart.RefreshPainter(serie); - serie.GetSerieData(dataIndex).context.highlighted = true; + serie.GetSerieData(dataIndex).context.highlight = true; serie.context.pointerItemDataIndex = dataIndex; } else { if (lastDataIndex >= 0) - serie.GetSerieData(lastDataIndex).context.highlighted = false; + serie.GetSerieData(lastDataIndex).context.highlight = false; serie.context.pointerItemDataIndex = -1; } } @@ -151,7 +151,7 @@ namespace XCharts if (lastPointerEnter) { foreach (var serieData in serie.data) - serieData.context.highlighted = false; + serieData.context.highlight = false; } serie.context.pointerItemDataIndex = -1; } @@ -213,7 +213,7 @@ namespace XCharts serieData.context.outsideRadius = serie.pieRoseType > 0 ? serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) : serie.context.outsideRadius; - if (serieData.context.highlighted) + if (serieData.context.highlight) { serieData.context.outsideRadius += chart.theme.serie.pieTooltipExtraRadius; } @@ -311,13 +311,13 @@ namespace XCharts { continue; } - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight); if (serieData.IsDataChanged()) dataChanging = true; var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName); var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount, - serieData.context.highlighted); + serieData.context.highlight); var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount, - serieData.context.highlighted); + serieData.context.highlight); var borderWidth = itemStyle.borderWidth; var borderColor = itemStyle.borderColor; @@ -372,7 +372,7 @@ namespace XCharts { foreach (var serieData in serie.data) { - if (serieData.context.highlighted) return true; + if (serieData.context.highlight) return true; } } } @@ -480,7 +480,7 @@ namespace XCharts { if (serieData.labelObject == null) return; var currAngle = serieData.context.halfAngle; - var isHighlight = (serieData.context.highlighted && serie.emphasis.label.show); + var isHighlight = (serieData.context.highlight && serie.emphasis.label.show); var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); var iconStyle = SerieHelper.GetIconStyle(serie, serieData); diff --git a/Assets/XCharts/Runtime/Serie/Radar/RadarHandler.cs b/Assets/XCharts/Runtime/Serie/Radar/RadarHandler.cs index 225f37cc..4b230e9e 100644 --- a/Assets/XCharts/Runtime/Serie/Radar/RadarHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Radar/RadarHandler.cs @@ -247,7 +247,7 @@ namespace XCharts private bool IsHighlight(RadarCoord radar, Serie serie, SerieData serieData, Tooltip tooltip, int dataIndex, int dimension) { - if (serie.highlighted || serieData.context.highlighted) return true; + if (serie.highlight || serieData.context.highlight) return true; if (tooltip == null) return false; var selectedSerieIndex = tooltip.runtimeDataIndex[0]; if (selectedSerieIndex < 0) return false; @@ -406,7 +406,7 @@ namespace XCharts { var serieData = serie.data[j]; if (!serieData.show) continue; - var isHighlight = serie.highlighted || serieData.context.highlighted || + var isHighlight = serie.highlight || serieData.context.highlight || (tooltip.show && tooltip.runtimeDataIndex[0] == i && tooltip.runtimeDataIndex[1] == j); var serieIndex = serieData.index; var symbolSize = isHighlight diff --git a/Assets/XCharts/Runtime/Serie/Ring/RingHandler.cs b/Assets/XCharts/Runtime/Serie/Ring/RingHandler.cs index aa1efff5..093ce8b6 100644 --- a/Assets/XCharts/Runtime/Serie/Ring/RingHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Ring/RingHandler.cs @@ -84,9 +84,9 @@ namespace XCharts var degree = (float)(360 * value / max); var startDegree = GetStartAngle(serie); var toDegree = GetToAngle(serie, degree); - var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlighted); - var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlighted); - var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlighted); + var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight); + var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight); + var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight); var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.ringGap); var insideRadius = outsideRadius - ringWidth; var centerRadius = (outsideRadius + insideRadius) / 2; diff --git a/Assets/XCharts/Runtime/Serie/Scatter/BaseScatterHandler.cs b/Assets/XCharts/Runtime/Serie/Scatter/BaseScatterHandler.cs index 2027dcc1..c73837ee 100644 --- a/Assets/XCharts/Runtime/Serie/Scatter/BaseScatterHandler.cs +++ b/Assets/XCharts/Runtime/Serie/Scatter/BaseScatterHandler.cs @@ -89,7 +89,7 @@ namespace XCharts var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize); if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize) { - serieData.context.highlighted = true; + serieData.context.highlight = true; serie.context.pointerItemDataIndex = lastDataIndex; return; } @@ -98,7 +98,7 @@ namespace XCharts serie.context.pointerItemDataIndex = -1; if (lastDataIndex >= 0) { - serie.GetSerieData(lastDataIndex).context.highlighted = false; + serie.GetSerieData(lastDataIndex).context.highlight = false; chart.RefreshPainter(serie); } for (int i = serie.dataCount - 1; i >= 0; i--) @@ -112,7 +112,7 @@ namespace XCharts var symbolSize = symbol.GetSize(serieData.data, themeSymbolSize); if (Vector3.Distance(serieData.context.position, chart.pointerPos) <= symbolSize) { - serieData.context.highlighted = true; + serieData.context.highlight = true; serie.context.pointerItemDataIndex = i; serie.context.pointerEnter = true; chart.RefreshPainter(serie); @@ -165,7 +165,7 @@ namespace XCharts if (!symbol.ShowSymbol(serieData.index, maxCount)) continue; - var highlight = serie.highlighted || serieData.context.highlighted; + var highlight = serie.highlight || serieData.context.highlight; var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); @@ -191,7 +191,7 @@ namespace XCharts var datas = serieData.data; float symbolSize = 0; - if (serie.highlighted || serieData.context.highlighted) + if (serie.highlight || serieData.context.highlight) { symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize); } @@ -267,7 +267,7 @@ namespace XCharts if (!symbol.ShowSymbol(serieData.index, maxCount)) continue; - var highlight = serie.highlighted || serieData.context.highlighted; + var highlight = serie.highlight || serieData.context.highlight; var color = SerieHelper.GetItemColor(serie, serieData, theme, colorIndex, highlight); var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight); var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false); @@ -296,7 +296,7 @@ namespace XCharts var datas = serieData.data; var symbolSize = 0f; - if (serie.highlighted || serieData.context.highlighted) + if (serie.highlight || serieData.context.highlight) symbolSize = symbol.GetSelectedSize(datas, theme.serie.scatterSymbolSelectedSize); else symbolSize = symbol.GetSize(datas, theme.serie.scatterSymbolSize); diff --git a/Assets/XCharts/Runtime/Serie/Serie.cs b/Assets/XCharts/Runtime/Serie/Serie.cs index 08ed710f..31960bee 100644 --- a/Assets/XCharts/Runtime/Serie/Serie.cs +++ b/Assets/XCharts/Runtime/Serie/Serie.cs @@ -232,7 +232,7 @@ namespace XCharts [SerializeField] private float[] m_Radius = new float[2] { 0, 80 }; [SerializeField] private LabelStyle m_Label = new LabelStyle(); [SerializeField] private LabelLine m_LabelLine = new LabelLine(); - [SerializeField] private SerieAnimation m_Animation = new SerieAnimation(); + [SerializeField] private AnimationStyle m_Animation = new AnimationStyle(); [SerializeField] private LineArrow m_LineArrow = new LineArrow(); [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle(); [SerializeField] private Emphasis m_Emphasis = new Emphasis(); @@ -745,7 +745,7 @@ namespace XCharts /// The start animation. /// 起始动画。 /// - public SerieAnimation animation + public AnimationStyle animation { get { return m_Animation; } set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); } @@ -981,7 +981,7 @@ namespace XCharts /// Whether the serie is highlighted. /// 该系列是否高亮,一般由图例悬停触发。 /// - public bool highlighted { get; internal set; } + public bool highlight { get; internal set; } /// /// the count of data list. /// 数据项个数。 @@ -1575,9 +1575,9 @@ namespace XCharts /// public void ClearHighlight() { - highlighted = false; + highlight = false; foreach (var serieData in m_Data) - serieData.context.highlighted = false; + serieData.context.highlight = false; } /// @@ -1587,7 +1587,7 @@ namespace XCharts { var serieData = GetSerieData(index); if (serieData != null) - serieData.context.highlighted = flag; + serieData.context.highlight = flag; } public float GetBarWidth(float categoryWidth) diff --git a/Assets/XCharts/Runtime/Serie/SerieData.cs b/Assets/XCharts/Runtime/Serie/SerieData.cs index d1a1837c..512f13e9 100644 --- a/Assets/XCharts/Runtime/Serie/SerieData.cs +++ b/Assets/XCharts/Runtime/Serie/SerieData.cs @@ -115,7 +115,7 @@ namespace XCharts m_Show = true; m_Selected = false; context.canShowLabel = true; - context.highlighted = false; + context.highlight = false; m_Radius = 0; m_Data.Clear(); m_PreviousData.Clear(); diff --git a/Assets/XCharts/Runtime/Serie/SerieDataContext.cs b/Assets/XCharts/Runtime/Serie/SerieDataContext.cs index cea05a58..f0281774 100644 --- a/Assets/XCharts/Runtime/Serie/SerieDataContext.cs +++ b/Assets/XCharts/Runtime/Serie/SerieDataContext.cs @@ -58,7 +58,7 @@ namespace XCharts /// Whether the data item is highlighted. /// 该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。 /// - public bool highlighted { get; set; } + public bool highlight { get; set; } } } \ No newline at end of file