From 6a76f25b7d3f157c85daa0d9bd0c0336c5a6db66 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 27 Apr 2021 12:47:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E5=A5=BD=E7=9A=84=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/BaseChartEditor.cs | 16 +- Runtime/Component/Main/Axis.cs | 4 +- Runtime/Component/Main/Serie.cs | 4 +- Runtime/Component/Main/Tooltip.cs | 23 +- Runtime/Component/Sub/SerieAnimation.cs | 2 +- Runtime/Component/Sub/SerieData.cs | 8 +- Runtime/{Internal => }/Helper/AxisHelper.cs | 16 +- .../{Internal => }/Helper/AxisHelper.cs.meta | 2 +- .../{Internal => }/Helper/ItemStyleHelper.cs | 4 +- .../Helper/ItemStyleHelper.cs.meta | 2 +- Runtime/{Internal => }/Helper/LegendHelper.cs | 2 +- .../Helper/LegendHelper.cs.meta | 2 +- Runtime/Helper/SerieHelper.cs | 413 +++++++++++++++++ .../{Internal => }/Helper/SerieLabelHelper.cs | 2 +- .../Helper/SerieLabelHelper.cs.meta | 2 +- Runtime/{Internal => }/Helper/SeriesHelper.cs | 36 +- .../Helper/SeriesHelper.cs.meta | 2 +- Runtime/{Internal => }/Helper/ThemeHelper.cs | 2 +- .../{Internal => }/Helper/ThemeHelper.cs.meta | 2 +- .../{Internal => }/Helper/TitleStyleHelper.cs | 2 +- .../Helper/TitleStyleHelper.cs.meta | 2 +- .../{Internal => }/Helper/TooltipHelper.cs | 2 +- .../Helper/TooltipHelper.cs.meta | 2 +- .../{Internal => }/Helper/VisualMapHelper.cs | 6 +- .../Helper/VisualMapHelper.cs.meta | 2 +- Runtime/Internal/BaseChart.cs | 4 +- Runtime/Internal/CoordinateChart.cs | 40 +- Runtime/Internal/CoordinateChart_DrawBar.cs | 72 +-- .../CoordinateChart_DrawCandlestick.cs | 4 +- Runtime/Internal/CoordinateChart_DrawGantt.cs | 2 +- Runtime/Internal/CoordinateChart_DrawLine.cs | 126 +++--- Runtime/Internal/Helper/PolarHelper.cs | 4 +- Runtime/Internal/Helper/SerieHelper.cs | 427 ------------------ Runtime/Internal/Helper/SerieHelper.cs.meta | 11 - Runtime/Internal/Helper/VesselHelper.cs | 4 +- 35 files changed, 611 insertions(+), 643 deletions(-) rename Runtime/{Internal => }/Helper/AxisHelper.cs (94%) rename Runtime/{Internal => }/Helper/AxisHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/ItemStyleHelper.cs (88%) rename Runtime/{Internal => }/Helper/ItemStyleHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/LegendHelper.cs (99%) rename Runtime/{Internal => }/Helper/LegendHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/SerieLabelHelper.cs (99%) rename Runtime/{Internal => }/Helper/SerieLabelHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/SeriesHelper.cs (92%) rename Runtime/{Internal => }/Helper/SeriesHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/ThemeHelper.cs (94%) rename Runtime/{Internal => }/Helper/ThemeHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/TitleStyleHelper.cs (96%) rename Runtime/{Internal => }/Helper/TitleStyleHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/TooltipHelper.cs (99%) rename Runtime/{Internal => }/Helper/TooltipHelper.cs.meta (83%) rename Runtime/{Internal => }/Helper/VisualMapHelper.cs (92%) rename Runtime/{Internal => }/Helper/VisualMapHelper.cs.meta (83%) delete mode 100644 Runtime/Internal/Helper/SerieHelper.cs delete mode 100644 Runtime/Internal/Helper/SerieHelper.cs.meta diff --git a/Editor/BaseChartEditor.cs b/Editor/BaseChartEditor.cs index c547fca2..78c331f8 100644 --- a/Editor/BaseChartEditor.cs +++ b/Editor/BaseChartEditor.cs @@ -129,22 +129,17 @@ namespace XCharts { EditorGUILayout.PropertyField(m_Script); EditorGUILayout.PropertyField(m_ChartName); - } - BlockEnd(); - var fileds = m_Chart.GetCustomChartInspectorShowFileds(); - if (fileds != null && fileds.Length > 0) - { - BlockStart(); - m_CustomFoldout = EditorGUILayout.Foldout(m_CustomFoldout, "Custom", true); - if (m_CustomFoldout) + var fileds = m_Chart.GetCustomChartInspectorShowFileds(); + if (fileds != null && fileds.Length > 0) { foreach (var filed in fileds) { EditorGUILayout.PropertyField(serializedObject.FindProperty(filed)); } } - BlockEnd(); } + BlockEnd(); + BlockField(m_Theme); BlockField(m_Settings); BlockField(m_Background); @@ -220,7 +215,8 @@ namespace XCharts var rect1 = new Rect(currRect.width + k_IconXOffset, currRect.y + k_IconYOffset, k_IconWidth, EditorGUIUtility.singleLineHeight); - if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd, ChartEditorHelper.Styles.invisibleButton)) + EditorGUI.DrawRect(rect1, Color.blue); + if (GUI.Button(rect1, ChartEditorHelper.Styles.iconAdd))// ChartEditorHelper.Styles.invisibleButton)) { prop.InsertArrayElementAtIndex(prop.arraySize > 0 ? prop.arraySize - 1 : 0); var chart = prop.GetArrayElementAtIndex(0).serializedObject.targetObject as BaseChart; diff --git a/Runtime/Component/Main/Axis.cs b/Runtime/Component/Main/Axis.cs index c80e4374..f83bcb82 100644 --- a/Runtime/Component/Main/Axis.cs +++ b/Runtime/Component/Main/Axis.cs @@ -757,7 +757,7 @@ namespace XCharts } } - internal float GetCurrMinValue(float duration) + public float GetCurrMinValue(float duration) { if (!Application.isPlaying) return m_RuntimeMinValue; if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0; @@ -777,7 +777,7 @@ namespace XCharts } } - internal float GetCurrMaxValue(float duration) + public float GetCurrMaxValue(float duration) { if (!Application.isPlaying) return m_RuntimeMaxValue; if (m_RuntimeMinValue == 0 && m_RuntimeMaxValue == 0) return 0; diff --git a/Runtime/Component/Main/Serie.cs b/Runtime/Component/Main/Serie.cs index 11aa390e..250d8968 100644 --- a/Runtime/Component/Main/Serie.cs +++ b/Runtime/Component/Main/Serie.cs @@ -1029,7 +1029,7 @@ namespace XCharts public float runtimePieDataTotal { get; internal set; } public float runtimeWaveSpeed { get; internal set; } public Painter runtimeCanvas { get; internal set; } - internal float runtimeCheckValue { get; set; } + public float runtimeCheckValue { get; set; } public int runtimeGridIndex { get; internal set; } public float runtimeX { get; internal set; } public float runtimeY { get; internal set; } @@ -1644,7 +1644,7 @@ namespace XCharts } } - internal float GetBarWidth(float categoryWidth) + public float GetBarWidth(float categoryWidth) { if (m_BarWidth > 1) return m_BarWidth; else return m_BarWidth * categoryWidth; diff --git a/Runtime/Component/Main/Tooltip.cs b/Runtime/Component/Main/Tooltip.cs index 162d6def..14e57ccc 100644 --- a/Runtime/Component/Main/Tooltip.cs +++ b/Runtime/Component/Main/Tooltip.cs @@ -74,7 +74,7 @@ namespace XCharts private Image m_ContentImage; private RectTransform m_ContentRect; private RectTransform m_ContentTextRect; - private List lastDataIndex { get; set; } + private List lastDataIndex = new List(); /// /// Whether to show the tooltip component. @@ -246,22 +246,25 @@ namespace XCharts /// /// 当前提示框所指示的Serie索引(目前只对散点图有效)。 /// - public Dictionary> runtimeSerieIndex { get; internal set; } + public Dictionary> runtimeSerieIndex = new Dictionary>(); /// /// The data index currently indicated by Tooltip. /// 当前提示框所指示的数据项索引。 /// - public List runtimeDataIndex { get; internal set; } + public List runtimeDataIndex { get { return m_RuntimeDateIndex; } internal set { m_RuntimeDateIndex = value; } } + private List m_RuntimeDateIndex = new List() { -1, -1 }; /// /// the value for x indicator label. /// 指示器X轴上要显示的值。 /// - public float[] runtimeXValues { get; internal set; } + public float[] runtimeXValues { get { return m_RuntimeXValue; } internal set { m_RuntimeXValue = value; } } + private float[] m_RuntimeXValue = new float[2] { -1, -1 }; /// /// the value for y indicator label. /// 指示器Y轴上要显示的值。 /// - public float[] runtimeYValues { get; internal set; } + public float[] runtimeYValues { get { return m_RuntimeYValue; } internal set { m_RuntimeYValue = value; } } + private float[] m_RuntimeYValue = new float[2] { -1, -1 }; /// /// the current pointer position. /// 当前鼠标位置。 @@ -303,12 +306,7 @@ namespace XCharts { var tooltip = new Tooltip { - m_Show = true, - runtimeXValues = new float[2] { -1, -1 }, - runtimeYValues = new float[2] { -1, -1 }, - runtimeDataIndex = new List() { -1, -1 }, - lastDataIndex = new List() { -1, -1 }, - runtimeSerieIndex = new Dictionary>() + m_Show = true }; return tooltip; } @@ -438,7 +436,8 @@ namespace XCharts public void SetActive(bool flag) { if (!flag && m_AlwayShow) return; - lastDataIndex[0] = lastDataIndex[1] = -1; + if (lastDataIndex.Count >= 2) + lastDataIndex[0] = lastDataIndex[1] = -1; if (m_GameObject && m_GameObject.activeInHierarchy != flag) m_GameObject.SetActive(flag); } diff --git a/Runtime/Component/Sub/SerieAnimation.cs b/Runtime/Component/Sub/SerieAnimation.cs index 13c08f64..db0fe31b 100644 --- a/Runtime/Component/Sub/SerieAnimation.cs +++ b/Runtime/Component/Sub/SerieAnimation.cs @@ -438,7 +438,7 @@ namespace XCharts } } - internal void AllBarEnd() + public void AllBarEnd() { End(); } diff --git a/Runtime/Component/Sub/SerieData.cs b/Runtime/Component/Sub/SerieData.cs index 2eac1bc5..b82f6f9a 100644 --- a/Runtime/Component/Sub/SerieData.cs +++ b/Runtime/Component/Sub/SerieData.cs @@ -191,10 +191,10 @@ namespace XCharts /// /// 绘制区域。 /// - public Rect runtimeRect { get; internal set; } - public float runtimeAngle { get; internal set; } - public Vector3 runtiemPieOffsetCenter { get; internal set; } - public float runtimeStackHig { get; internal set; } + public Rect runtimeRect { get; set; } + public float runtimeAngle { get; set; } + public Vector3 runtiemPieOffsetCenter { get; set; } + public float runtimeStackHig { get; set; } private List m_PreviousData = new List(); private List m_DataUpdateTime = new List(); private List m_DataUpdateFlag = new List(); diff --git a/Runtime/Internal/Helper/AxisHelper.cs b/Runtime/Helper/AxisHelper.cs similarity index 94% rename from Runtime/Internal/Helper/AxisHelper.cs rename to Runtime/Helper/AxisHelper.cs index c7c258ba..32f1d575 100644 --- a/Runtime/Internal/Helper/AxisHelper.cs +++ b/Runtime/Helper/AxisHelper.cs @@ -124,7 +124,7 @@ namespace XCharts /// /// /// - internal static string GetLabelName(Axis axis, float coordinateWidth, int index, float minValue, float maxValue, + public static string GetLabelName(Axis axis, float coordinateWidth, int index, float minValue, float maxValue, DataZoom dataZoom, bool forcePercent) { int split = GetSplitNumber(axis, coordinateWidth, dataZoom); @@ -208,7 +208,7 @@ namespace XCharts /// /// /// - internal static int GetScaleNumber(Axis axis, float coordinateWidth, DataZoom dataZoom = null) + public static int GetScaleNumber(Axis axis, float coordinateWidth, DataZoom dataZoom = null) { int splitNum = GetSplitNumber(axis, coordinateWidth, dataZoom); if (axis.IsCategory()) @@ -232,7 +232,7 @@ namespace XCharts /// /// /// - internal static float GetScaleWidth(Axis axis, float coordinateWidth, int index, DataZoom dataZoom = null) + public static float GetScaleWidth(Axis axis, float coordinateWidth, int index, DataZoom dataZoom = null) { if (index < 0) return 0; int num = GetScaleNumber(axis, coordinateWidth, dataZoom); @@ -268,7 +268,7 @@ namespace XCharts } } - internal static float GetEachWidth(Axis axis, float coordinateWidth, DataZoom dataZoom = null) + public static float GetEachWidth(Axis axis, float coordinateWidth, DataZoom dataZoom = null) { var data = axis.GetDataList(); if (data.Count > 0) @@ -288,7 +288,7 @@ namespace XCharts /// /// /// - internal static void AdjustMinMaxValue(Axis axis, ref float minValue, ref float maxValue, bool needFormat, int ceilRate = 0) + public static void AdjustMinMaxValue(Axis axis, ref float minValue, ref float maxValue, bool needFormat, int ceilRate = 0) { if (axis.type == Axis.AxisType.Log) { @@ -357,7 +357,7 @@ namespace XCharts } } - internal static bool NeedShowSplit(Axis axis) + public static bool NeedShowSplit(Axis axis) { if (!axis.show) return false; if (axis.IsCategory() && axis.GetDataList().Count <= 0) return false; @@ -365,7 +365,7 @@ namespace XCharts else return true; } - internal static void AdjustCircleLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset) + public static void AdjustCircleLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset) { var txtWidth = txt.GetPreferredWidth(); var sizeDelta = new Vector2(txtWidth, txt.GetPreferredHeight()); @@ -387,7 +387,7 @@ namespace XCharts txt.SetLocalPosition(pos + offset); } - internal static void AdjustRadiusAxisLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset) + public static void AdjustRadiusAxisLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset) { var txtWidth = txt.GetPreferredWidth(); var sizeDelta = new Vector2(txtWidth, txt.GetPreferredHeight()); diff --git a/Runtime/Internal/Helper/AxisHelper.cs.meta b/Runtime/Helper/AxisHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/AxisHelper.cs.meta rename to Runtime/Helper/AxisHelper.cs.meta index c911707b..5de4b001 100644 --- a/Runtime/Internal/Helper/AxisHelper.cs.meta +++ b/Runtime/Helper/AxisHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 502c2be6d197b40f59ae65d9c659700f +guid: ca154a2444b924ff98ce6091280227c8 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/ItemStyleHelper.cs b/Runtime/Helper/ItemStyleHelper.cs similarity index 88% rename from Runtime/Internal/Helper/ItemStyleHelper.cs rename to Runtime/Helper/ItemStyleHelper.cs index c8576ff3..e451647a 100644 --- a/Runtime/Internal/Helper/ItemStyleHelper.cs +++ b/Runtime/Helper/ItemStyleHelper.cs @@ -4,12 +4,10 @@ /* https://github.com/monitor1394 */ /* */ /************************************************/ -using UnityEngine; -using UnityEngine.UI; namespace XCharts { - internal static class ItemStyleHelper + public static class ItemStyleHelper { public static bool IsNeedCorner(ItemStyle itemStyle) { diff --git a/Runtime/Internal/Helper/ItemStyleHelper.cs.meta b/Runtime/Helper/ItemStyleHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/ItemStyleHelper.cs.meta rename to Runtime/Helper/ItemStyleHelper.cs.meta index 31a149f1..4ea0dbd4 100644 --- a/Runtime/Internal/Helper/ItemStyleHelper.cs.meta +++ b/Runtime/Helper/ItemStyleHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 14c20b85c2c6d44b08f57c928307080d +guid: 521b0ebf9d94445ec8478185c82da10f MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/LegendHelper.cs b/Runtime/Helper/LegendHelper.cs similarity index 99% rename from Runtime/Internal/Helper/LegendHelper.cs rename to Runtime/Helper/LegendHelper.cs index 7cb29792..4b82f3f0 100644 --- a/Runtime/Internal/Helper/LegendHelper.cs +++ b/Runtime/Helper/LegendHelper.cs @@ -9,7 +9,7 @@ using UnityEngine.UI; namespace XCharts { - internal static class LegendHelper + public static class LegendHelper { public static Color GetContentColor(Legend legend, ChartTheme theme, bool active) { diff --git a/Runtime/Internal/Helper/LegendHelper.cs.meta b/Runtime/Helper/LegendHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/LegendHelper.cs.meta rename to Runtime/Helper/LegendHelper.cs.meta index 8d21df83..7699195c 100644 --- a/Runtime/Internal/Helper/LegendHelper.cs.meta +++ b/Runtime/Helper/LegendHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d03ce7a11ecde41b6930883612bf8f05 +guid: 270acce470d13484f926a0468376b324 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Helper/SerieHelper.cs b/Runtime/Helper/SerieHelper.cs index 8cd45d72..6d34bcf3 100644 --- a/Runtime/Helper/SerieHelper.cs +++ b/Runtime/Helper/SerieHelper.cs @@ -5,6 +5,7 @@ /* */ /************************************************/ +using System.Collections.Generic; using System.Text; using UnityEngine; @@ -127,5 +128,417 @@ namespace XCharts serie.runtimeCenterPos = chartPosition + new Vector3(chartWidth / 2, chartHeight / 2); } } + + public static Color32 GetItemBackgroundColor(Serie serie, SerieData serieData, ChartTheme theme, int index, + bool highlight, bool useDefault = true) + { + var color = ChartConst.clearColor32; + if (highlight) + { + var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); + if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.backgroundColor)) + { + color = itemStyleEmphasis.backgroundColor; + ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); + return color; + } + } + var itemStyle = GetItemStyle(serie, serieData); + if (!ChartHelper.IsClearColor(itemStyle.backgroundColor)) + { + color = itemStyle.backgroundColor; + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + else if (useDefault) + { + color = theme.GetColor(index); + if (highlight) color = ChartHelper.GetHighlightColor(color); + color.a = 50; + return color; + } + return color; + } + + public static Color32 GetItemColor(Serie serie, SerieData serieData, ChartTheme theme, int index, bool highlight) + { + if (serie == null) return ChartConst.clearColor32; + if (highlight) + { + var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); + if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) + { + var color = itemStyleEmphasis.color; + ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); + return color; + } + } + var itemStyle = GetItemStyle(serie, serieData); + if (!ChartHelper.IsClearColor(itemStyle.color)) + { + return itemStyle.GetColor(); + } + else + { + var color = theme.GetColor(index); + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + } + public static Color32 GetItemColor0(Serie serie, SerieData serieData, ChartTheme theme, bool highlight, Color32 defaultColor) + { + if (serie == null) return ChartConst.clearColor32; + if (highlight) + { + var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); + if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) + { + var color = itemStyleEmphasis.color0; + ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); + return color; + } + } + var itemStyle = GetItemStyle(serie, serieData); + if (!ChartHelper.IsClearColor(itemStyle.color0)) + { + return itemStyle.GetColor0(); + } + else + { + var color = defaultColor; + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + } + + public static Color32 GetItemToColor(Serie serie, SerieData serieData, ChartTheme theme, int index, bool highlight) + { + if (highlight) + { + var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); + if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.toColor)) + { + return itemStyleEmphasis.GetColor(); + } + } + var itemStyle = GetItemStyle(serie, serieData, highlight); + if (itemStyle == null) itemStyle = serieData.itemStyle; + if (!ChartHelper.IsClearColor(itemStyle.toColor)) + { + var color = itemStyle.toColor; + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + if (!ChartHelper.IsClearColor(itemStyle.color)) + { + var color = itemStyle.color; + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + else + { + var color = theme.GetColor(index); + if (highlight) color = ChartHelper.GetHighlightColor(color); + ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); + return color; + } + } + + public static bool IsDownPoint(Serie serie, int index) + { + var dataPoints = serie.dataPoints; + if (dataPoints.Count < 2) return false; + else if (index > 0 && index < dataPoints.Count - 1) + { + var lp = dataPoints[index - 1]; + var np = dataPoints[index + 1]; + var cp = dataPoints[index]; + var dot = Vector3.Cross(np - lp, cp - np); + return dot.z < 0; + } + else if (index == 0) + { + return dataPoints[0].y < dataPoints[1].y; + } + else if (index == dataPoints.Count - 1) + { + return dataPoints[index].y < dataPoints[index - 1].y; + } + else + { + return false; + } + } + + public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false) + { + if (highlight) + { + var style = GetItemStyleEmphasis(serie, serieData); + if (style == null) return GetItemStyle(serie, serieData, false); + else return style; + } + else if (serie.IsPerformanceMode()) return serie.itemStyle; + else if (serieData != null && serieData.enableItemStyle) return serieData.itemStyle; + else return serie.itemStyle; + } + + public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData) + { + if (!serie.IsPerformanceMode() && serieData != null && serieData.enableEmphasis && serieData.emphasis.show) + return serieData.emphasis.itemStyle; + else if (serie.emphasis.show) return serie.emphasis.itemStyle; + else return null; + } + + public static SerieLabel GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false) + { + if (highlight) + { + if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show) + return serieData.emphasis.label; + else if (serie.emphasis.show) return serie.emphasis.label; + else return serie.label; + } + else + { + if (!serie.IsPerformanceMode() && serieData.enableLabel) return serieData.label; + else return serie.label; + } + } + + public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData) + { + if (!serie.IsPerformanceMode() && serieData.enableSymbol) return serieData.symbol; + else return serie.symbol; + } + + public static Color32 GetAreaColor(Serie serie, ChartTheme theme, int index, bool highlight) + { + var areaStyle = serie.areaStyle; + var color = !ChartHelper.IsClearColor(areaStyle.color) ? areaStyle.color : theme.GetColor(index); + if (highlight) + { + if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) color = areaStyle.highlightColor; + else color = ChartHelper.GetHighlightColor(color); + } + ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); + return color; + } + + public static Color32 GetAreaToColor(Serie serie, ChartTheme theme, int index, bool highlight) + { + var areaStyle = serie.areaStyle; + if (!ChartHelper.IsClearColor(areaStyle.toColor)) + { + var color = areaStyle.toColor; + if (highlight) + { + if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) color = areaStyle.highlightToColor; + else color = ChartHelper.GetHighlightColor(color); + } + ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); + return color; + } + else + { + return GetAreaColor(serie, theme, index, highlight); + } + } + + public static Color32 GetLineColor(Serie serie, ChartTheme theme, int index, bool highlight) + { + Color32 color = ChartConst.clearColor32; + if (highlight) + { + var itemStyleEmphasis = GetItemStyleEmphasis(serie, null); + if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) + { + color = itemStyleEmphasis.color; + ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); + return color; + } + } + if (!ChartHelper.IsClearColor(serie.lineStyle.color)) color = serie.lineStyle.GetColor(); + else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.GetColor(); + if (ChartHelper.IsClearColor(color)) + { + color = theme.GetColor(index); + ChartHelper.SetColorOpacity(ref color, serie.lineStyle.opacity); + } + if (highlight) color = ChartHelper.GetHighlightColor(color); + return color; + } + + public static float GetSymbolBorder(Serie serie, SerieData serieData, ChartTheme theme, bool highlight, bool useLineWidth = true) + { + var itemStyle = GetItemStyle(serie, serieData, highlight); + if (itemStyle != null && itemStyle.borderWidth != 0) return itemStyle.borderWidth; + else return serie.lineStyle.GetWidth(theme.serie.lineWidth); + } + + public static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight) + { + var itemStyle = GetItemStyle(serie, serieData, highlight); + if (itemStyle != null) return itemStyle.cornerRadius; + else return null; + } + + public static string GetNumericFormatter(Serie serie, SerieData serieData) + { + var itemStyle = SerieHelper.GetItemStyle(serie, serieData); + if (!string.IsNullOrEmpty(itemStyle.numericFormatter)) return itemStyle.numericFormatter; + else return string.Empty; + } + + /// + /// 获得指定维数的最大最小值 + /// + /// + /// + /// + public static void UpdateMinMaxData(Serie serie, int dimension, int ceilRate = 0, DataZoom dataZoom = null) + { + float min = 0, max = 0; + GetMinMaxData(serie, dimension, out min, out max, dataZoom); + if (ceilRate < 0) + { + serie.runtimeDataMin = min; + serie.runtimeDataMax = max; + } + else + { + serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate); + serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate); + } + } + + public static void GetAllMinMaxData(Serie serie, int ceilRate = 0, DataZoom dataZoom = null) + { + float min = 0, max = 0; + GetMinMaxData(serie, out min, out max, dataZoom); + if (ceilRate < 0) + { + serie.runtimeDataMin = min; + serie.runtimeDataMax = max; + } + else + { + serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate); + serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate); + } + } + + private static List emptyFilter = new List(); + /// + /// 根据dataZoom更新数据列表缓存 + /// + /// + public static void UpdateFilterData(Serie serie, DataZoom dataZoom) + { + if (dataZoom == null || !dataZoom.enable) return; + if (dataZoom.xAxisIndexs.Contains(serie.xAxisIndex)) + { + if (dataZoom.IsXAxisIndexValue(serie.xAxisIndex)) + { + float min = 0, max = 0; + dataZoom.GetXAxisIndexValue(serie.xAxisIndex, out min, out max); + UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max); + } + else + { + UpdateFilterData_Category(serie, dataZoom); + } + } + else if (dataZoom.yAxisIndexs.Contains(serie.yAxisIndex)) + { + if (dataZoom.IsYAxisIndexValue(serie.yAxisIndex)) + { + float min = 0, max = 0; + dataZoom.GetYAxisIndexValue(serie.yAxisIndex, out min, out max); + UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max); + } + else + { + UpdateFilterData_Category(serie, dataZoom); + } + } + } + + private static void UpdateFilterData_XAxisValue(Serie serie, DataZoom dataZoom, int dimension, float min, float max) + { + var data = serie.data; + var startValue = min + (max - min) * dataZoom.start / 100; + var endValue = min + (max - min) * dataZoom.end / 100; + if (endValue < startValue) endValue = startValue; + + if (startValue != serie.m_FilterStartValue || endValue != serie.m_FilterEndValue + || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData) + { + serie.m_FilterStartValue = startValue; + serie.m_FilterEndValue = endValue; + serie.m_FilterMinShow = dataZoom.minShowNum; + serie.m_NeedUpdateFilterData = false; + + serie.m_FilterData.Clear(); + foreach (var serieData in data) + { + var value = serieData.GetData(dimension); + if (value >= startValue && value <= endValue) + { + serie.m_FilterData.Add(serieData); + } + } + } + else if (endValue == 0) + { + serie.m_FilterData = emptyFilter; + } + } + + private static void UpdateFilterData_Category(Serie serie, DataZoom dataZoom) + { + var data = serie.data; + var startIndex = (int)((data.Count - 1) * dataZoom.start / 100); + var endIndex = (int)((data.Count - 1) * dataZoom.end / 100); + if (endIndex < startIndex) endIndex = startIndex; + + if (startIndex != serie.m_FilterStart || endIndex != serie.m_FilterEnd + || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData) + { + serie.m_FilterStart = startIndex; + serie.m_FilterEnd = endIndex; + serie.m_FilterMinShow = dataZoom.minShowNum; + serie.m_NeedUpdateFilterData = false; + var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1; + if (count < dataZoom.minShowNum) + { + if (dataZoom.minShowNum > data.Count) count = data.Count; + else count = dataZoom.minShowNum; + } + if (data.Count > 0) + { + if (startIndex + count > data.Count) + { + int start = endIndex - count; + data = data.GetRange(start < 0 ? 0 : start, count); + } + else serie.m_FilterData = data.GetRange(startIndex, count); + } + else + { + serie.m_FilterData = data; + } + } + else if (endIndex == 0) + { + serie.m_FilterData = emptyFilter; + } + } } } \ No newline at end of file diff --git a/Runtime/Internal/Helper/SerieLabelHelper.cs b/Runtime/Helper/SerieLabelHelper.cs similarity index 99% rename from Runtime/Internal/Helper/SerieLabelHelper.cs rename to Runtime/Helper/SerieLabelHelper.cs index de20e4a5..dd9205e0 100644 --- a/Runtime/Internal/Helper/SerieLabelHelper.cs +++ b/Runtime/Helper/SerieLabelHelper.cs @@ -232,7 +232,7 @@ namespace XCharts } } - internal static void AvoidLabelOverlap(Serie serie) + public static void AvoidLabelOverlap(Serie serie) { if (!serie.avoidLabelOverlap) return; var lastCheckPos = Vector3.zero; diff --git a/Runtime/Internal/Helper/SerieLabelHelper.cs.meta b/Runtime/Helper/SerieLabelHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/SerieLabelHelper.cs.meta rename to Runtime/Helper/SerieLabelHelper.cs.meta index a2e2a477..5b4a31fa 100644 --- a/Runtime/Internal/Helper/SerieLabelHelper.cs.meta +++ b/Runtime/Helper/SerieLabelHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bbd57df98f6f145f299cf942b04229a4 +guid: 0b81cddd3452545748563f9c6ea9be69 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/SeriesHelper.cs b/Runtime/Helper/SeriesHelper.cs similarity index 92% rename from Runtime/Internal/Helper/SeriesHelper.cs rename to Runtime/Helper/SeriesHelper.cs index 50f88a3c..9e698a2e 100644 --- a/Runtime/Internal/Helper/SeriesHelper.cs +++ b/Runtime/Helper/SeriesHelper.cs @@ -89,7 +89,7 @@ namespace XCharts /// 获得所有系列名,不包含空名字。 /// /// - internal static void UpdateSerieNameList(Series series, ref List serieNameList) + public static void UpdateSerieNameList(Series series, ref List serieNameList) { serieNameList.Clear(); for (int n = 0; n < series.list.Count; n++) @@ -119,7 +119,7 @@ namespace XCharts } } - internal static Color GetNameColor(Series series, int index, string name, ChartTheme theme) + public static Color GetNameColor(Series series, int index, string name, ChartTheme theme) { Serie destSerie = null; SerieData destSerieData = null; @@ -160,7 +160,7 @@ namespace XCharts /// /// /// - internal static bool IsAnyGradientSerie(Series series, string stack) + public static bool IsAnyGradientSerie(Series series, string stack) { if (string.IsNullOrEmpty(stack)) return false; foreach (var serie in series.list) @@ -179,7 +179,7 @@ namespace XCharts /// 是否有需裁剪的serie。 /// /// - internal static bool IsAnyClipSerie(Series series) + public static bool IsAnyClipSerie(Series series) { foreach (var serie in series.list) { @@ -188,7 +188,7 @@ namespace XCharts return false; } - internal static bool ContainsSerie(Series series, SerieType type) + public static bool ContainsSerie(Series series, SerieType type) { foreach (var serie in series.list) { @@ -197,7 +197,7 @@ namespace XCharts return false; } - internal static bool IsAnyUpdateAnimationSerie(Series series) + public static bool IsAnyUpdateAnimationSerie(Series series) { foreach (var serie in series.list) { @@ -214,7 +214,7 @@ namespace XCharts /// /// /// - internal static Serie GetLastStackSerie(Series series, Serie serie) + public static Serie GetLastStackSerie(Series series, Serie serie) { if (serie == null || string.IsNullOrEmpty(serie.stack)) return null; for (int i = serie.index - 1; i >= 0; i--) @@ -230,13 +230,13 @@ namespace XCharts /// /// /// - internal static Serie GetLastStackSerie(Series series, int index) + public static Serie GetLastStackSerie(Series series, int index) { var serie = series.GetSerie(index); return GetLastStackSerie(series, serie); } - internal static Serie GetSerieByVesselIndex(Series series, int vesselIndex) + public static Serie GetSerieByVesselIndex(Series series, int vesselIndex) { foreach (var serie in series.list) { @@ -250,7 +250,7 @@ namespace XCharts /// 是否由数据堆叠 /// /// - internal static bool IsStack(Series series) + public static bool IsStack(Series series) { _setForStack.Clear(); foreach (var serie in series.list) @@ -271,7 +271,7 @@ namespace XCharts /// /// /// - internal static bool IsStack(Series series, string stackName, SerieType type) + public static bool IsStack(Series series, string stackName, SerieType type) { if (string.IsNullOrEmpty(stackName)) return false; int count = 0; @@ -291,7 +291,7 @@ namespace XCharts /// /// /// - internal static bool IsPercentStack(Series series, SerieType type) + public static bool IsPercentStack(Series series, SerieType type) { int count = 0; bool isPercentStack = false; @@ -316,7 +316,7 @@ namespace XCharts /// /// /// - internal static bool IsPercentStack(Series series, string stackName, SerieType type) + public static bool IsPercentStack(Series series, string stackName, SerieType type) { if (string.IsNullOrEmpty(stackName)) return false; int count = 0; @@ -342,7 +342,7 @@ namespace XCharts /// /// /// - internal static void GetStackSeries(Series series, ref Dictionary> stackSeries) + public static void GetStackSeries(Series series, ref Dictionary> stackSeries) { int count = 0; var serieCount = series.list.Count; @@ -388,7 +388,7 @@ namespace XCharts } } - internal static void UpdateStackDataList(Series series, Serie currSerie, DataZoom dataZoom, List> dataList) + public static void UpdateStackDataList(Series series, Serie currSerie, DataZoom dataZoom, List> dataList) { dataList.Clear(); for (int i = 0; i <= currSerie.index; i++) @@ -408,7 +408,7 @@ namespace XCharts /// /// /// - internal static void GetXMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, + public static void GetXMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse, out float minVaule, out float maxValue, bool isPolar = false) { GetMinMaxValue(series, dataZoom, axisIndex, isValueAxis, inverse, false, out minVaule, out maxValue, isPolar); @@ -421,7 +421,7 @@ namespace XCharts /// /// /// - internal static void GetYMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, + public static void GetYMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse, out float minVaule, out float maxValue, bool isPolar = false) { GetMinMaxValue(series, dataZoom, axisIndex, isValueAxis, inverse, true, out minVaule, out maxValue, isPolar); @@ -429,7 +429,7 @@ namespace XCharts private static Dictionary> _stackSeriesForMinMax = new Dictionary>(); private static Dictionary _serieTotalValueForMinMax = new Dictionary(); - internal static void GetMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, + public static void GetMinMaxValue(Series series, DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse, bool yValue, out float minVaule, out float maxValue, bool isPolar = false) { float min = int.MaxValue; diff --git a/Runtime/Internal/Helper/SeriesHelper.cs.meta b/Runtime/Helper/SeriesHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/SeriesHelper.cs.meta rename to Runtime/Helper/SeriesHelper.cs.meta index 5ad2501f..bda31ead 100644 --- a/Runtime/Internal/Helper/SeriesHelper.cs.meta +++ b/Runtime/Helper/SeriesHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e7411a13172764cf89b10e643089c832 +guid: 96a06a5949772464da15c44ae2ad400d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/ThemeHelper.cs b/Runtime/Helper/ThemeHelper.cs similarity index 94% rename from Runtime/Internal/Helper/ThemeHelper.cs rename to Runtime/Helper/ThemeHelper.cs index 293ec750..1e9f4fba 100644 --- a/Runtime/Internal/Helper/ThemeHelper.cs +++ b/Runtime/Helper/ThemeHelper.cs @@ -9,7 +9,7 @@ using UnityEngine; namespace XCharts { - internal static class ThemeHelper + public static class ThemeHelper { public static Color32 GetBackgroundColor(ChartTheme theme, Background background) { diff --git a/Runtime/Internal/Helper/ThemeHelper.cs.meta b/Runtime/Helper/ThemeHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/ThemeHelper.cs.meta rename to Runtime/Helper/ThemeHelper.cs.meta index 31fb98b7..ec6997a4 100644 --- a/Runtime/Internal/Helper/ThemeHelper.cs.meta +++ b/Runtime/Helper/ThemeHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5093880c2dbba4c01bb0231653ed3252 +guid: cb35a91a23492484aa6f873b5ba75e57 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/TitleStyleHelper.cs b/Runtime/Helper/TitleStyleHelper.cs similarity index 96% rename from Runtime/Internal/Helper/TitleStyleHelper.cs rename to Runtime/Helper/TitleStyleHelper.cs index e8fb1f26..fee3d172 100644 --- a/Runtime/Internal/Helper/TitleStyleHelper.cs +++ b/Runtime/Helper/TitleStyleHelper.cs @@ -9,7 +9,7 @@ using UnityEngine.UI; namespace XCharts { - internal static class TitleStyleHelper + public static class TitleStyleHelper { public static void CheckTitle(Serie serie, ref bool m_ReinitTitle, ref bool m_UpdateTitleText) { diff --git a/Runtime/Internal/Helper/TitleStyleHelper.cs.meta b/Runtime/Helper/TitleStyleHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/TitleStyleHelper.cs.meta rename to Runtime/Helper/TitleStyleHelper.cs.meta index 5b0e40c0..71ca21a6 100644 --- a/Runtime/Internal/Helper/TitleStyleHelper.cs.meta +++ b/Runtime/Helper/TitleStyleHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 35fa58aecc0f4414e8a2f03195b66175 +guid: c0215e7ec59ca4e4fb55b19ed02213c9 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/TooltipHelper.cs b/Runtime/Helper/TooltipHelper.cs similarity index 99% rename from Runtime/Internal/Helper/TooltipHelper.cs rename to Runtime/Helper/TooltipHelper.cs index dade1d1b..838797d5 100644 --- a/Runtime/Internal/Helper/TooltipHelper.cs +++ b/Runtime/Helper/TooltipHelper.cs @@ -10,7 +10,7 @@ using UnityEngine; namespace XCharts { - internal static class TooltipHelper + public static class TooltipHelper { private static void InitScatterTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ChartTheme theme) diff --git a/Runtime/Internal/Helper/TooltipHelper.cs.meta b/Runtime/Helper/TooltipHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/TooltipHelper.cs.meta rename to Runtime/Helper/TooltipHelper.cs.meta index ca8bc73d..c22cf36f 100644 --- a/Runtime/Internal/Helper/TooltipHelper.cs.meta +++ b/Runtime/Helper/TooltipHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f0fa1b19683a8424bb335802de5c9726 +guid: ae34edb52008c442984c29a57197188a MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/Helper/VisualMapHelper.cs b/Runtime/Helper/VisualMapHelper.cs similarity index 92% rename from Runtime/Internal/Helper/VisualMapHelper.cs rename to Runtime/Helper/VisualMapHelper.cs index dde186ce..f219d3b7 100644 --- a/Runtime/Internal/Helper/VisualMapHelper.cs +++ b/Runtime/Helper/VisualMapHelper.cs @@ -68,7 +68,7 @@ namespace XCharts } } - internal static Color32 GetLineGradientColor(VisualMap visualMap, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) + public static Color32 GetLineGradientColor(VisualMap visualMap, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) { float value = 0; switch (visualMap.direction) @@ -102,7 +102,7 @@ namespace XCharts else return color; } - internal static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) + public static Color32 GetItemStyleGradientColor(ItemStyle itemStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) { var min = axis.runtimeMinValue; var max = axis.runtimeMaxValue; @@ -114,7 +114,7 @@ namespace XCharts else return color; } - internal static Color32 GetLineStyleGradientColor(LineStyle lineStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) + public static Color32 GetLineStyleGradientColor(LineStyle lineStyle, Vector3 pos, CoordinateChart chart, Axis axis, Color32 defaultColor) { var min = axis.runtimeMinValue; var max = axis.runtimeMaxValue; diff --git a/Runtime/Internal/Helper/VisualMapHelper.cs.meta b/Runtime/Helper/VisualMapHelper.cs.meta similarity index 83% rename from Runtime/Internal/Helper/VisualMapHelper.cs.meta rename to Runtime/Helper/VisualMapHelper.cs.meta index 2183dfde..c1e825dd 100644 --- a/Runtime/Internal/Helper/VisualMapHelper.cs.meta +++ b/Runtime/Helper/VisualMapHelper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 15e5106bd46f5484596429d512f6af5d +guid: 870f899098b0f42bdb4552ed65464c60 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index bab616e2..4342f316 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -152,7 +152,7 @@ namespace XCharts CheckTooltip(); CheckRefreshChart(); CheckRefreshLabel(); - CheckAnimation(); + Internal_CheckAnimation(); foreach (var draw in m_DrawSeries) draw.Update(); } @@ -716,7 +716,7 @@ namespace XCharts } } - protected void CheckAnimation() + public void Internal_CheckAnimation() { if (!m_CheckAnimation) { diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index abd809e5..e83d683f 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -1702,7 +1702,7 @@ namespace XCharts var content = ""; if (anyPercentStack && isPercentStack) { - var tempTotal = GetSameStackTotalValue(serie.stack, j); + var tempTotal = Internal_GetBarSameStackTotalValue(serie.stack, j); content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, tempTotal, serieLabel, theme.GetColor(i)); } @@ -1958,13 +1958,13 @@ namespace XCharts RefreshChart(); } - protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, + public void Internal_CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Color32 color, bool clip, Grid grid) { - CheckClipAndDrawPolygon(vh, p1, p2, p3, p4, color, color, clip, grid); + Internal_CheckClipAndDrawPolygon(vh, p1, p2, p3, p4, color, color, clip, grid); } - protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p, float radius, Color32 color, + public void Internal_CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p, float radius, Color32 color, bool clip, bool vertical, Grid grid) { if (!IsInChart(p)) return; @@ -1972,7 +1972,7 @@ namespace XCharts UGL.DrawSquare(vh, p, radius, color); } - protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, + public void Internal_CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Color32 startColor, Color32 toColor, bool clip, Grid grid) { ClampInChart(ref p1); @@ -1990,7 +1990,7 @@ namespace XCharts UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor); } - protected void CheckClipAndDrawPolygon(VertexHelper vh, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, ref Vector3 p4, + public void Internal_CheckClipAndDrawPolygon(VertexHelper vh, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, ref Vector3 p4, Color32 startColor, Color32 toColor, bool clip, Grid grid) { ClampInChart(ref p1); @@ -2009,13 +2009,13 @@ namespace XCharts UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor); } - protected void CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Color32 color, + public void Internal_CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Color32 color, bool clip, Grid grid) { - CheckClipAndDrawTriangle(vh, p1, p2, p3, color, color, color, clip, grid); + Internal_CheckClipAndDrawTriangle(vh, p1, p2, p3, color, color, color, clip, grid); } - protected void CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Color32 color, + public void Internal_CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3, bool clip, Grid grid) { if (!IsInChart(p1) || !IsInChart(p2) || !IsInChart(p3)) return; @@ -2023,7 +2023,7 @@ namespace XCharts UGL.DrawTriangle(vh, p1, p2, p3, color, color2, color3); } - protected void CheckClipAndDrawLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, Color32 color, + public void Internal_CheckClipAndDrawLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, Color32 color, bool clip, Grid grid) { if (!IsInChart(p1) || !IsInChart(p2)) return; @@ -2031,7 +2031,7 @@ namespace XCharts UGL.DrawLine(vh, p1, p2, size, color); } - protected void CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness, + public void Internal_CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize, float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, bool clip, float[] cornerRadius, Grid grid) { if (!IsInChart(pos)) return; @@ -2039,7 +2039,7 @@ namespace XCharts DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius); } - protected void CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth, + public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth, float zebraGap, Color32 color, bool clip, Grid grid) { ClampInChart(ref p1); @@ -2059,7 +2059,7 @@ namespace XCharts return Color32.Lerp(areaToColor, areaColor, (pos.x - grid.runtimeX) / grid.runtimeWidth); } - internal Grid GetAxisGridOrDefault(Axis axis) + public Grid GetAxisGridOrDefault(Axis axis) { var index = axis.gridIndex; if (index >= 0 && index < m_Grids.Count) @@ -2076,7 +2076,7 @@ namespace XCharts } } - protected Grid GetDataZoomGridOrDefault(DataZoom dataZoom) + public Grid GetDataZoomGridOrDefault(DataZoom dataZoom) { var xAxis = GetXAxis(dataZoom.xAxisIndexs[0]); Grid grid = GetGrid(xAxis.gridIndex); @@ -2106,7 +2106,7 @@ namespace XCharts return grid; } - protected XAxis GetSerieXAxisOrDefault(Serie serie) + public XAxis GetSerieXAxisOrDefault(Serie serie) { var axis = GetXAxis(serie.xAxisIndex); if (axis == null) @@ -2117,7 +2117,7 @@ namespace XCharts return axis; } - protected YAxis GetSerieYAxisOrDefault(Serie serie) + public YAxis GetSerieYAxisOrDefault(Serie serie) { var axis = GetYAxis(serie.yAxisIndex); if (axis == null) @@ -2139,7 +2139,7 @@ namespace XCharts } } - private float GetXAxisOnZeroOffset(XAxis axis) + public float GetXAxisOnZeroOffset(XAxis axis) { if (!axis.axisLine.onZero) return 0; foreach (var yAxis in m_YAxes) @@ -2149,7 +2149,7 @@ namespace XCharts return 0; } - private float GetYAxisOnZeroOffset(YAxis axis) + public float GetYAxisOnZeroOffset(YAxis axis) { if (!axis.axisLine.onZero) return 0; foreach (var xAxis in m_XAxes) @@ -2159,7 +2159,7 @@ namespace XCharts return 0; } - private YAxis GetRelatedYAxis(XAxis axis) + public YAxis GetRelatedYAxis(XAxis axis) { foreach (var yAxis in m_YAxes) { @@ -2168,7 +2168,7 @@ namespace XCharts return m_YAxes[0]; } - private XAxis GetRelatedXAxis(YAxis axis) + public XAxis GetRelatedXAxis(YAxis axis) { foreach (var xAxis in m_XAxes) { diff --git a/Runtime/Internal/CoordinateChart_DrawBar.cs b/Runtime/Internal/CoordinateChart_DrawBar.cs index 5ccdac71..680efc25 100644 --- a/Runtime/Internal/CoordinateChart_DrawBar.cs +++ b/Runtime/Internal/CoordinateChart_DrawBar.cs @@ -27,12 +27,12 @@ namespace XCharts var grid = GetSerieGridOrDefault(serie); var showData = serie.GetDataList(dataZoom); float categoryWidth = AxisHelper.GetDataWidth(yAxis, grid.runtimeHeight, showData.Count, dataZoom); - float barGap = GetBarGap(); - float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap); + float barGap = Internal_GetBarGap(); + float totalBarWidth = Internal_GetBarTotalWidth(categoryWidth, barGap); float barWidth = serie.GetBarWidth(categoryWidth); float offset = (categoryWidth - totalBarWidth) / 2; float barGapWidth = barWidth + barWidth * barGap; - float space = serie.barGap == -1 ? offset : offset + GetBarIndex(serie) * barGapWidth; + float space = serie.barGap == -1 ? offset : offset + Internal_GetBarIndex(serie) * barGapWidth; var isStack = SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar); m_StackSerieData.Clear(); if (isStack) SeriesHelper.UpdateStackDataList(m_Series, serie, dataZoom, m_StackSerieData); @@ -81,7 +81,7 @@ namespace XCharts var valueTotal = 0f; if (isPercentStack) { - valueTotal = GetSameStackTotalValue(serie.stack, i); + valueTotal = Internal_GetBarSameStackTotalValue(serie.stack, i); barHig = valueTotal != 0 ? (value / valueTotal * grid.runtimeWidth) : 0; } else @@ -93,7 +93,7 @@ namespace XCharts } serieData.runtimeStackHig = barHig; var isBarEnd = false; - float currHig = CheckAnimation(serie, i, barHig, out isBarEnd); + float currHig = Internal_CheckBarAnimation(serie, i, barHig, out isBarEnd); if (!isBarEnd) isAllBarEnd = false; Vector3 plt, prt, prb, plb, top; if (value < 0) @@ -143,7 +143,7 @@ namespace XCharts } } - private float CheckAnimation(Serie serie, int dataIndex, float barHig, out bool isBarEnd) + public float Internal_CheckBarAnimation(Serie serie, int dataIndex, float barHig, out bool isBarEnd) { float currHig = serie.animation.CheckBarProgress(dataIndex, barHig, serie.dataCount, out isBarEnd); if (!serie.animation.IsFinish()) @@ -166,12 +166,12 @@ namespace XCharts m_StackSerieData.Clear(); if (isStack) SeriesHelper.UpdateStackDataList(m_Series, serie, dataZoom, m_StackSerieData); float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.runtimeWidth, showData.Count, dataZoom); - float barGap = GetBarGap(); - float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap); + float barGap = Internal_GetBarGap(); + float totalBarWidth = Internal_GetBarTotalWidth(categoryWidth, barGap); float barWidth = serie.GetBarWidth(categoryWidth); float offset = (categoryWidth - totalBarWidth) / 2; float barGapWidth = barWidth + barWidth * barGap; - float space = serie.barGap == -1 ? offset : offset + GetBarIndex(serie) * barGapWidth; + float space = serie.barGap == -1 ? offset : offset + Internal_GetBarIndex(serie) * barGapWidth; int maxCount = serie.maxShow > 0 ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) : showData.Count; @@ -215,7 +215,7 @@ namespace XCharts var valueTotal = 0f; if (isPercentStack) { - valueTotal = GetSameStackTotalValue(serie.stack, i); + valueTotal = Internal_GetBarSameStackTotalValue(serie.stack, i); barHig = valueTotal != 0 ? (value / valueTotal * grid.runtimeHeight) : 0; } else @@ -228,7 +228,7 @@ namespace XCharts } serieData.runtimeStackHig = barHig; var isBarEnd = false; - float currHig = CheckAnimation(serie, i, barHig, out isBarEnd); + float currHig = Internal_CheckBarAnimation(serie, i, barHig, out isBarEnd); if (!isBarEnd) isAllBarEnd = false; Vector3 plb, plt, prt, prb, top; if (value < 0) @@ -313,7 +313,7 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid); } UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor, itemStyle.borderToColor, 0, itemStyle.cornerRadius, isYAxis); @@ -340,7 +340,7 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor, + Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor, serie.clip, grid); } UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, itemStyle.borderColor, @@ -359,14 +359,14 @@ namespace XCharts { plt = (plb + plt) / 2; prt = (prt + prb) / 2; - CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, + Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, areaColor, serie.clip, grid); } else { plb = (prb + plb) / 2; plt = (plt + prt) / 2; - CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, + Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, areaColor, serie.clip, grid); } } @@ -395,14 +395,14 @@ namespace XCharts var barLen = prt.x - plt.x; var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen); var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen); - CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor, + Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor, rectEndColor, serie.clip, grid); UGL.DrawSector(vh, pcl, radius, areaColor, rectStartColor, 180, 360, 1, isYAxis); UGL.DrawSector(vh, pcr, radius, rectEndColor, areaToColor, 0, 180, 1, isYAxis); } else { - CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, + Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, areaToColor, serie.clip, grid); UGL.DrawSector(vh, pcl, radius, areaColor, 180, 360); UGL.DrawSector(vh, pcr, radius, areaToColor, 0, 180); @@ -420,14 +420,14 @@ namespace XCharts var barLen = plt.x - prt.x; var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen); var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen); - CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor, + Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor, rectEndColor, serie.clip, grid); UGL.DrawSector(vh, pcl, radius, rectStartColor, areaColor, 0, 180, 1, isYAxis); UGL.DrawSector(vh, pcr, radius, areaToColor, rectEndColor, 180, 360, 1, isYAxis); } else { - CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor, + Internal_CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor, areaToColor, serie.clip, grid); UGL.DrawSector(vh, pcl, radius, areaColor, 0, 180); UGL.DrawSector(vh, pcr, radius, areaToColor, 180, 360); @@ -449,14 +449,14 @@ namespace XCharts var barLen = plt.y - plb.y; var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen); var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen); - CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor, + Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor, rectEndColor, serie.clip, grid); UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 270, 450, 1, isYAxis); UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 90, 270, 1, isYAxis); } else { - CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, + Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, areaToColor, serie.clip, grid); UGL.DrawSector(vh, pct, radius, areaToColor, 270, 450); UGL.DrawSector(vh, pcb, radius, areaColor, 90, 270); @@ -474,14 +474,14 @@ namespace XCharts var barLen = plb.y - plt.y; var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen); var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen); - CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor, + Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor, rectEndColor, serie.clip, grid); UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 90, 270, 1, isYAxis); UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 270, 450, 1, isYAxis); } else { - CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor, + Internal_CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor, areaToColor, serie.clip, grid); UGL.DrawSector(vh, pct, radius, areaToColor, 90, 270); UGL.DrawSector(vh, pcb, radius, areaColor, 270, 450); @@ -510,7 +510,7 @@ namespace XCharts var diff = Vector3.right * radius; var pcl = (plt + plb) / 2 + diff; var pcr = (prt + prb) / 2 - diff; - CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip, grid); UGL.DrawSector(vh, pcl, radius, color, 180, 360); UGL.DrawSector(vh, pcr, radius, color, 0, 180); if (itemStyle.NeedShowBorder()) @@ -534,7 +534,7 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip, grid); } } else @@ -551,7 +551,7 @@ namespace XCharts var diff = Vector3.up * radius; var pct = (plt + prt) / 2 - diff; var pcb = (plb + prb) / 2 + diff; - CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color, + Internal_CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color, serie.clip, grid); UGL.DrawSector(vh, pct, radius, color, 270, 450); UGL.DrawSector(vh, pcb, radius, color, 90, 270); @@ -576,18 +576,18 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid); } } } - private float GetBarGap() + public float Internal_GetBarGap() { float gap = 0.3f; for (int i = 0; i < m_Series.Count; i++) { var serie = m_Series.list[i]; - if (serie.type == SerieType.Bar || serie.type == SerieType.Candlestick) + if (serie.type == SerieType.Bar || serie.type == SerieType.Candlestick || serie.type == SerieType.Custom) { if (serie.barGap != 0) { @@ -598,13 +598,13 @@ namespace XCharts return gap; } - private float GetSameStackTotalValue(string stack, int dataIndex) + public float Internal_GetBarSameStackTotalValue(string stack, int dataIndex) { if (string.IsNullOrEmpty(stack)) return 0; float total = 0; foreach (var serie in m_Series.list) { - if (serie.type == SerieType.Bar) + if (serie.type == SerieType.Bar || serie.type == SerieType.Custom) { if (stack.Equals(serie.stack)) { @@ -617,7 +617,7 @@ namespace XCharts private HashSet barStackSet = new HashSet(); - private float GetBarTotalWidth(float categoryWidth, float gap) + public float Internal_GetBarTotalWidth(float categoryWidth, float gap) { float total = 0; float lastGap = 0; @@ -626,7 +626,7 @@ namespace XCharts { var serie = m_Series.list[i]; if (!serie.show) continue; - if (serie.type == SerieType.Bar || serie.type == SerieType.Candlestick) + if (serie.type == SerieType.Bar || serie.type == SerieType.Candlestick || serie.type == SerieType.Custom) { if (!string.IsNullOrEmpty(serie.stack)) { @@ -657,7 +657,7 @@ namespace XCharts for (int i = 0; i < m_Series.Count; i++) { var serie = m_Series.list[i]; - if ((serie.type == SerieType.Bar && serie.type == SerieType.Candlestick) + if ((serie.type == SerieType.Bar || serie.type == SerieType.Candlestick || serie.type == SerieType.Custom) && serie.show && now.stack.Equals(serie.stack)) { if (serie.barWidth > barWidth) barWidth = serie.barWidth; @@ -668,14 +668,14 @@ namespace XCharts } private List tempList = new List(); - private int GetBarIndex(Serie currSerie) + public int Internal_GetBarIndex(Serie currSerie) { tempList.Clear(); int index = 0; for (int i = 0; i < m_Series.Count; i++) { var serie = m_Series.GetSerie(i); - if (serie.type != SerieType.Bar) continue; + if (serie.type != SerieType.Bar || serie.type == SerieType.Custom) continue; if (string.IsNullOrEmpty(serie.stack)) { if (serie.index == currSerie.index) return index; diff --git a/Runtime/Internal/CoordinateChart_DrawCandlestick.cs b/Runtime/Internal/CoordinateChart_DrawCandlestick.cs index 6cf30b06..c56e680a 100644 --- a/Runtime/Internal/CoordinateChart_DrawCandlestick.cs +++ b/Runtime/Internal/CoordinateChart_DrawCandlestick.cs @@ -69,7 +69,7 @@ namespace XCharts } serieData.runtimeStackHig = barHig; var isBarEnd = false; - float currHig = CheckAnimation(serie, i, barHig, out isBarEnd); + float currHig = Internal_CheckBarAnimation(serie, i, barHig, out isBarEnd); if (!isBarEnd) isAllBarEnd = false; Vector3 plb, plt, prt, prb, top; @@ -111,7 +111,7 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaColor, + Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaColor, serie.clip, grid); } UGL.DrawBorder(vh, center, itemWidth, itemHeight, 2 * borderWidth, borderColor, 0, diff --git a/Runtime/Internal/CoordinateChart_DrawGantt.cs b/Runtime/Internal/CoordinateChart_DrawGantt.cs index d62a6926..171f7d80 100644 --- a/Runtime/Internal/CoordinateChart_DrawGantt.cs +++ b/Runtime/Internal/CoordinateChart_DrawGantt.cs @@ -141,7 +141,7 @@ namespace XCharts } else { - CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, + Internal_CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid); } if (borderWidth != 0) diff --git a/Runtime/Internal/CoordinateChart_DrawLine.cs b/Runtime/Internal/CoordinateChart_DrawLine.cs index d33eca0e..13d3873a 100644 --- a/Runtime/Internal/CoordinateChart_DrawLine.cs +++ b/Runtime/Internal/CoordinateChart_DrawLine.cs @@ -45,7 +45,7 @@ namespace XCharts var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); symbolSize = serie.animation.GetSysmbolSize(symbolSize); - CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serie.dataPoints[i], symbolColor, + Internal_CheckClipAndDrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serie.dataPoints[i], symbolColor, symbolToColor, symbol.gap, clip, cornerRadius, grid); } } @@ -773,8 +773,8 @@ namespace XCharts { isShort = true; isStart = true; - CheckClipAndDrawPolygon(vh, stPos1, upPos1, upPos2, stPos2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, stPos2, upPos2, dnPos, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, stPos1, upPos1, upPos2, stPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, stPos2, upPos2, dnPos, lineColor, serie.clip, grid); TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, stPos1, isEndPos); TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, upPos1, isEndPos); TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, dnPos, isEndPos); @@ -784,7 +784,7 @@ namespace XCharts (!lastIsDown && IsInRightOrUp(isYAxis, lastDnPos, tp1))) { isStart = true; - CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid); } } else @@ -793,24 +793,24 @@ namespace XCharts { if (np != nnp) { - CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip, grid); } else { - CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip, grid); } } else { if (IsInRightOrUp(isYAxis, tp2, dnPos) || isTurnBack) { - CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, serie.clip, grid); } else { - CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip, grid); i = segment; } } @@ -834,11 +834,11 @@ namespace XCharts isStart = true; isShort = true; if (np == nnp) - CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos2, stPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos2, stPos2, lineColor, serie.clip, grid); else { - CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos1, stPos2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, dnPos, upPos1, upPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, stPos1, dnPos, upPos1, stPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, dnPos, upPos1, upPos2, lineColor, serie.clip, grid); } TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, dnPos, isEndPos); TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, stPos2, isEndPos); @@ -851,7 +851,7 @@ namespace XCharts isStart = true; if (stPos2 != Vector3.zero) { - CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip, grid); } } } @@ -861,21 +861,21 @@ namespace XCharts { if (np != nnp) { - CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip, grid); } - else CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip, grid); + else Internal_CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip, grid); } else { if (IsInRightOrUp(isYAxis, tp1, dnPos) || isTurnBack) { - CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.GetWidth(m_Theme.serie.lineWidth), lineColor, serie.clip, grid); } else { - CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip, grid); i = segment; } } @@ -979,7 +979,7 @@ namespace XCharts if ((isYAxis && ep.y > luPos.y) || (!isYAxis && ep.x > luPos.x)) { var tp = isYAxis ? new Vector3(luPos.x, sp.y) : new Vector3(sp.x, luPos.y); - CheckClipAndDrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); break; } DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero); @@ -1001,7 +1001,7 @@ namespace XCharts { first = true; var tp = isYAxis ? new Vector3(rdPos.x, ep.y) : new Vector3(ep.x, rdPos.y); - CheckClipAndDrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor, serie.clip, grid); sp = ep; continue; } @@ -1025,7 +1025,7 @@ namespace XCharts if ((isYAxis && ep.y > rdPos.y) || (!isYAxis && ep.x > rdPos.x)) { var tp = isYAxis ? new Vector3(rdPos.x, sp.y) : new Vector3(sp.x, rdPos.y); - CheckClipAndDrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); break; } if (rdPos != Vector3.zero) DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero); @@ -1047,7 +1047,7 @@ namespace XCharts { first = true; var tp = isYAxis ? new Vector3(luPos.x, ep.y) : new Vector3(ep.x, luPos.y); - CheckClipAndDrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip, grid); sp = ep; continue; } @@ -1132,7 +1132,7 @@ namespace XCharts diff = isLessthan0 ? -lineWidth : lineWidth; areaColor = GetYLerpColor(areaColor, areaToColor, sp, grid); if (isLessthan0) areaDiff = -areaDiff; - CheckClipAndDrawPolygon(vh, new Vector3(zeroPos.x + diff, sp.y), new Vector3(zeroPos.x + diff, ep.y), + Internal_CheckClipAndDrawPolygon(vh, new Vector3(zeroPos.x + diff, sp.y), new Vector3(zeroPos.x + diff, ep.y), ep + areaDiff, sp + areaDiff, areaToColor, areaColor, clip, grid); } else @@ -1143,12 +1143,12 @@ namespace XCharts if (isLessthan0) areaDiff = -areaDiff; if (isLessthan0) { - CheckClipAndDrawPolygon(vh, ep + areaDiff, sp + areaDiff, new Vector3(sp.x, zeroPos.y + diff), + Internal_CheckClipAndDrawPolygon(vh, ep + areaDiff, sp + areaDiff, new Vector3(sp.x, zeroPos.y + diff), new Vector3(ep.x, zeroPos.y + diff), areaColor, areaToColor, clip, grid); } else { - CheckClipAndDrawPolygon(vh, sp + areaDiff, ep + areaDiff, new Vector3(ep.x, zeroPos.y + diff), + Internal_CheckClipAndDrawPolygon(vh, sp + areaDiff, ep + areaDiff, new Vector3(ep.x, zeroPos.y + diff), new Vector3(sp.x, zeroPos.y + diff), areaColor, areaToColor, clip, grid); } } @@ -1228,7 +1228,7 @@ namespace XCharts start = bezierPoints[i]; to = bezierPoints[i + 1]; CheckLineGradientColor(start, serie.lineStyle, xAxis, defaultLineColor, ref lineColor); - CheckClipAndDrawLine(vh, start, to, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, start, to, lineWidth, lineColor, serie.clip, grid); } return true; } @@ -1251,8 +1251,8 @@ namespace XCharts if (!serie.animation.IsInFadeOut()) { CheckLineGradientColor(lp, serie.lineStyle, xAxis, defaultLineColor, ref lineColor); - CheckClipAndDrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor, serie.clip, grid); - CheckClipAndDrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor, serie.clip, grid); TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, smoothStartPosUp, false); TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, smoothStartPosDn, false); } @@ -1279,8 +1279,8 @@ namespace XCharts toUp = to - diff; toDn = to + diff; CheckLineGradientColor(to, serie.lineStyle, xAxis, defaultLineColor, ref lineColor); - if (isYAxis) CheckClipAndDrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor, serie.clip, grid); - else CheckClipAndDrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor, serie.clip, grid); + if (isYAxis) Internal_CheckClipAndDrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor, serie.clip, grid); + else Internal_CheckClipAndDrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor, serie.clip, grid); TryAddToList(isTurnBack, isYAxis, smoothPoints, lastSmoothPoint, toUp, true); TryAddToList(isTurnBack, isYAxis, smoothDownPoints, lastSmoothDownPoint, toDn, true); if (isEndPos) @@ -1383,12 +1383,12 @@ namespace XCharts if (k < lastSmoothPoints.Count - 1) { tnp = lastSmoothPoints[lastCount - 1]; - CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip, grid); while (lastCount < lastSmoothPoints.Count) { tlp = lastSmoothPoints[lastCount]; if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break; - CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip, grid); lastCount++; tnp = tlp; } @@ -1400,7 +1400,7 @@ namespace XCharts { tlp = lastSmoothPoints[lastSmoothPoints.Count - 1]; if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break; - CheckClipAndDrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor, serie.clip, grid); start = to; continue; } @@ -1410,7 +1410,7 @@ namespace XCharts { tlp = lastSmoothPoints[lastCount - 1]; if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break; - CheckClipAndDrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor, serie.clip, grid); lastCount++; } else @@ -1418,12 +1418,12 @@ namespace XCharts if (diff < 0) { tnp = lastSmoothPoints[lastCount - 1]; - CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip, grid); while (diff < 0 && lastCount < lastSmoothPoints.Count) { tlp = lastSmoothPoints[lastCount]; if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break; - CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip, grid); lastCount++; diff = isYAxis ? tlp.y - to.y : tlp.x - to.x; tnp = tlp; @@ -1433,7 +1433,7 @@ namespace XCharts { tlp = lastSmoothPoints[lastCount - 1]; if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break; - CheckClipAndDrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor, serie.clip, grid); } } start = to; @@ -1444,7 +1444,7 @@ namespace XCharts var p2 = lastSmoothPoints[lastSmoothPoints.Count - 1]; if (!serie.animation.CheckDetailBreak(p1, isYAxis) && !serie.animation.CheckDetailBreak(p2, isYAxis)) { - CheckClipAndDrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor, serie.clip, grid); + Internal_CheckClipAndDrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor, serie.clip, grid); } } } @@ -1477,15 +1477,15 @@ namespace XCharts { ep = linePointList[i]; if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); sp = ep; } - CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip, true, grid); } else { - if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); - CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip, grid); + if (dataIndex == 1) Internal_CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip, grid); } if (serie.areaStyle.show) { @@ -1505,7 +1505,7 @@ namespace XCharts { ep = linePointList[i]; if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); if (serie.areaStyle.show) { DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1516,7 +1516,7 @@ namespace XCharts if (nnp != np) { if (serie.animation.CheckDetailBreak(np, isYAxis)) return false; - CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); bool flag = ((isYAxis && nnp.x > np.x && np.x > zeroPos.x) || (!isYAxis && nnp.y > np.y && np.y > zeroPos.y)); if (serie.areaStyle.show && flag) { @@ -1542,7 +1542,7 @@ namespace XCharts { ep = linePointList[i]; if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); if (serie.areaStyle.show) { DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1550,7 +1550,7 @@ namespace XCharts sp = ep; } if (serie.animation.CheckDetailBreak(middle1, isYAxis)) return false; - CheckClipAndDrawPolygon(vh, middle1, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, middle1, lineWidth, lineColor, serie.clip, true, grid); if (serie.areaStyle.show && Vector3.Dot(middleZero - middle1, middle2 - middle1) <= 0) { DrawPolygonToZero(vh, middle1 - diff1, middle1 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1558,8 +1558,8 @@ namespace XCharts } else { - if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); - CheckClipAndDrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip, grid); + if (dataIndex == 1) Internal_CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip, grid); } //draw middle1 to middle2 @@ -1570,10 +1570,10 @@ namespace XCharts for (int i = 1; i < linePointList.Count; i++) { ep = linePointList[i]; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); sp = ep; } - CheckClipAndDrawPolygon(vh, middle2, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, middle2, lineWidth, lineColor, serie.clip, true, grid); if (serie.areaStyle.show && Vector3.Dot(middleZero - middle2, middle2 - middle1) >= 0) { DrawPolygonToZero(vh, middle2 - diff1, middle2 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1581,7 +1581,7 @@ namespace XCharts } else { - CheckClipAndDrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor, serie.clip, grid); } //draw middle2 to np if (Vector3.Distance(middle2, np) > 2 * lineWidth) @@ -1592,7 +1592,7 @@ namespace XCharts { ep = linePointList[i]; if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); if (serie.areaStyle.show) { DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1600,7 +1600,7 @@ namespace XCharts sp = ep; } if (serie.animation.CheckDetailBreak(np, isYAxis)) return false; - CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); if (serie.areaStyle.show) { DrawPolygonToZero(vh, np - diff1, np + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1608,7 +1608,7 @@ namespace XCharts } else { - CheckClipAndDrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip, grid); } break; case LineType.StepEnd: @@ -1627,7 +1627,7 @@ namespace XCharts { ep = linePointList[i]; if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); if (serie.areaStyle.show) { DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1635,7 +1635,7 @@ namespace XCharts sp = ep; } if (serie.animation.CheckDetailBreak(middle, isYAxis)) return false; - CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip, true, grid); if (serie.areaStyle.show && Vector3.Dot(np - middle, middleZero - middle) <= 0) { DrawPolygonToZero(vh, middle - diff1, middle + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff); @@ -1643,8 +1643,8 @@ namespace XCharts } else { - if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); - CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip, grid); + if (dataIndex == 1) Internal_CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip, true, grid); + Internal_CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip, grid); } if (Vector3.Distance(middle, np) > 2 * lineWidth) @@ -1654,14 +1654,14 @@ namespace XCharts for (int i = 1; i < linePointList.Count; i++) { ep = linePointList[i]; - CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip, grid); sp = ep; } - if (nnp != np) CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); + if (nnp != np) Internal_CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip, true, grid); } else { - CheckClipAndDrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor, serie.clip, grid); + Internal_CheckClipAndDrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor, serie.clip, grid); } bool flag2 = ((isYAxis && middle.x > np.x && np.x > zeroPos.x) || (!isYAxis && middle.y > np.y && np.y > zeroPos.y)); if (serie.areaStyle.show && flag2) diff --git a/Runtime/Internal/Helper/PolarHelper.cs b/Runtime/Internal/Helper/PolarHelper.cs index 07482db5..3d981871 100644 --- a/Runtime/Internal/Helper/PolarHelper.cs +++ b/Runtime/Internal/Helper/PolarHelper.cs @@ -9,9 +9,9 @@ using UnityEngine; namespace XCharts { - internal static class PolarHelper + public static class PolarHelper { - internal static void UpdatePolarCenter(Polar polar, Vector3 chartPosition, float chartWidth, float chartHeight) + public static void UpdatePolarCenter(Polar polar, Vector3 chartPosition, float chartWidth, float chartHeight) { if (polar.center.Length < 2) return; var centerX = polar.center[0] <= 1 ? chartWidth * polar.center[0] : polar.center[0]; diff --git a/Runtime/Internal/Helper/SerieHelper.cs b/Runtime/Internal/Helper/SerieHelper.cs deleted file mode 100644 index 0fe073bc..00000000 --- a/Runtime/Internal/Helper/SerieHelper.cs +++ /dev/null @@ -1,427 +0,0 @@ -/************************************************/ -/* */ -/* Copyright (c) 2018 - 2021 monitor1394 */ -/* https://github.com/monitor1394 */ -/* */ -/************************************************/ - -using System.Collections.Generic; -using UnityEngine; - -namespace XCharts -{ - public static partial class SerieHelper - { - internal static Color32 GetItemBackgroundColor(Serie serie, SerieData serieData, ChartTheme theme, int index, - bool highlight, bool useDefault = true) - { - var color = ChartConst.clearColor32; - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.backgroundColor)) - { - color = itemStyleEmphasis.backgroundColor; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; - } - } - var itemStyle = GetItemStyle(serie, serieData); - if (!ChartHelper.IsClearColor(itemStyle.backgroundColor)) - { - color = itemStyle.backgroundColor; - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - else if (useDefault) - { - color = theme.GetColor(index); - if (highlight) color = ChartHelper.GetHighlightColor(color); - color.a = 50; - return color; - } - return color; - } - - internal static Color32 GetItemColor(Serie serie, SerieData serieData, ChartTheme theme, int index, bool highlight) - { - if (serie == null) return ChartConst.clearColor32; - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) - { - var color = itemStyleEmphasis.color; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; - } - } - var itemStyle = GetItemStyle(serie, serieData); - if (!ChartHelper.IsClearColor(itemStyle.color)) - { - return itemStyle.GetColor(); - } - else - { - var color = theme.GetColor(index); - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - } - internal static Color32 GetItemColor0(Serie serie, SerieData serieData, ChartTheme theme, bool highlight, Color32 defaultColor) - { - if (serie == null) return ChartConst.clearColor32; - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) - { - var color = itemStyleEmphasis.color0; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; - } - } - var itemStyle = GetItemStyle(serie, serieData); - if (!ChartHelper.IsClearColor(itemStyle.color0)) - { - return itemStyle.GetColor0(); - } - else - { - var color = defaultColor; - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - } - - internal static Color32 GetItemToColor(Serie serie, SerieData serieData, ChartTheme theme, int index, bool highlight) - { - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, serieData); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.toColor)) - { - return itemStyleEmphasis.GetColor(); - } - } - var itemStyle = GetItemStyle(serie, serieData, highlight); - if (itemStyle == null) itemStyle = serieData.itemStyle; - if (!ChartHelper.IsClearColor(itemStyle.toColor)) - { - var color = itemStyle.toColor; - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - if (!ChartHelper.IsClearColor(itemStyle.color)) - { - var color = itemStyle.color; - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - else - { - var color = theme.GetColor(index); - if (highlight) color = ChartHelper.GetHighlightColor(color); - ChartHelper.SetColorOpacity(ref color, itemStyle.opacity); - return color; - } - } - - internal static bool IsDownPoint(Serie serie, int index) - { - var dataPoints = serie.dataPoints; - if (dataPoints.Count < 2) return false; - else if (index > 0 && index < dataPoints.Count - 1) - { - var lp = dataPoints[index - 1]; - var np = dataPoints[index + 1]; - var cp = dataPoints[index]; - var dot = Vector3.Cross(np - lp, cp - np); - return dot.z < 0; - } - else if (index == 0) - { - return dataPoints[0].y < dataPoints[1].y; - } - else if (index == dataPoints.Count - 1) - { - return dataPoints[index].y < dataPoints[index - 1].y; - } - else - { - return false; - } - } - - internal static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false) - { - if (highlight) - { - var style = GetItemStyleEmphasis(serie, serieData); - if (style == null) return GetItemStyle(serie, serieData, false); - else return style; - } - else if (serie.IsPerformanceMode()) return serie.itemStyle; - else if (serieData != null && serieData.enableItemStyle) return serieData.itemStyle; - else return serie.itemStyle; - } - - internal static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData) - { - if (!serie.IsPerformanceMode() && serieData != null && serieData.enableEmphasis && serieData.emphasis.show) - return serieData.emphasis.itemStyle; - else if (serie.emphasis.show) return serie.emphasis.itemStyle; - else return null; - } - - public static SerieLabel GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false) - { - if (highlight) - { - if (!serie.IsPerformanceMode() && serieData.enableEmphasis && serieData.emphasis.show) - return serieData.emphasis.label; - else if (serie.emphasis.show) return serie.emphasis.label; - else return serie.label; - } - else - { - if (!serie.IsPerformanceMode() && serieData.enableLabel) return serieData.label; - else return serie.label; - } - } - - internal static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData) - { - if (!serie.IsPerformanceMode() && serieData.enableSymbol) return serieData.symbol; - else return serie.symbol; - } - - internal static Color32 GetAreaColor(Serie serie, ChartTheme theme, int index, bool highlight) - { - var areaStyle = serie.areaStyle; - var color = !ChartHelper.IsClearColor(areaStyle.color) ? areaStyle.color : theme.GetColor(index); - if (highlight) - { - if (!ChartHelper.IsClearColor(areaStyle.highlightColor)) color = areaStyle.highlightColor; - else color = ChartHelper.GetHighlightColor(color); - } - ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); - return color; - } - - internal static Color32 GetAreaToColor(Serie serie, ChartTheme theme, int index, bool highlight) - { - var areaStyle = serie.areaStyle; - if (!ChartHelper.IsClearColor(areaStyle.toColor)) - { - var color = areaStyle.toColor; - if (highlight) - { - if (!ChartHelper.IsClearColor(areaStyle.highlightToColor)) color = areaStyle.highlightToColor; - else color = ChartHelper.GetHighlightColor(color); - } - ChartHelper.SetColorOpacity(ref color, areaStyle.opacity); - return color; - } - else - { - return GetAreaColor(serie, theme, index, highlight); - } - } - - internal static Color32 GetLineColor(Serie serie, ChartTheme theme, int index, bool highlight) - { - Color32 color = ChartConst.clearColor32; - if (highlight) - { - var itemStyleEmphasis = GetItemStyleEmphasis(serie, null); - if (itemStyleEmphasis != null && !ChartHelper.IsClearColor(itemStyleEmphasis.color)) - { - color = itemStyleEmphasis.color; - ChartHelper.SetColorOpacity(ref color, itemStyleEmphasis.opacity); - return color; - } - } - if (!ChartHelper.IsClearColor(serie.lineStyle.color)) color = serie.lineStyle.GetColor(); - else if (!ChartHelper.IsClearColor(serie.itemStyle.color)) color = serie.itemStyle.GetColor(); - if (ChartHelper.IsClearColor(color)) - { - color = theme.GetColor(index); - ChartHelper.SetColorOpacity(ref color, serie.lineStyle.opacity); - } - if (highlight) color = ChartHelper.GetHighlightColor(color); - return color; - } - - internal static float GetSymbolBorder(Serie serie, SerieData serieData, ChartTheme theme, bool highlight, bool useLineWidth = true) - { - var itemStyle = GetItemStyle(serie, serieData, highlight); - if (itemStyle != null && itemStyle.borderWidth != 0) return itemStyle.borderWidth; - else return serie.lineStyle.GetWidth(theme.serie.lineWidth); - } - - internal static float[] GetSymbolCornerRadius(Serie serie, SerieData serieData, bool highlight) - { - var itemStyle = GetItemStyle(serie, serieData, highlight); - if (itemStyle != null) return itemStyle.cornerRadius; - else return null; - } - - internal static string GetNumericFormatter(Serie serie, SerieData serieData) - { - var itemStyle = SerieHelper.GetItemStyle(serie, serieData); - if (!string.IsNullOrEmpty(itemStyle.numericFormatter)) return itemStyle.numericFormatter; - else return string.Empty; - } - - /// - /// 获得指定维数的最大最小值 - /// - /// - /// - /// - internal static void UpdateMinMaxData(Serie serie, int dimension, int ceilRate = 0, DataZoom dataZoom = null) - { - float min = 0, max = 0; - GetMinMaxData(serie, dimension, out min, out max, dataZoom); - if (ceilRate < 0) - { - serie.runtimeDataMin = min; - serie.runtimeDataMax = max; - } - else - { - serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate); - serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate); - } - } - - internal static void GetAllMinMaxData(Serie serie, int ceilRate = 0, DataZoom dataZoom = null) - { - float min = 0, max = 0; - GetMinMaxData(serie, out min, out max, dataZoom); - if (ceilRate < 0) - { - serie.runtimeDataMin = min; - serie.runtimeDataMax = max; - } - else - { - serie.runtimeDataMin = ChartHelper.GetMinDivisibleValue(min, ceilRate); - serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate); - } - } - - private static List emptyFilter = new List(); - /// - /// 根据dataZoom更新数据列表缓存 - /// - /// - internal static void UpdateFilterData(Serie serie, DataZoom dataZoom) - { - if (dataZoom == null || !dataZoom.enable) return; - if (dataZoom.xAxisIndexs.Contains(serie.xAxisIndex)) - { - if (dataZoom.IsXAxisIndexValue(serie.xAxisIndex)) - { - float min = 0, max = 0; - dataZoom.GetXAxisIndexValue(serie.xAxisIndex, out min, out max); - UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max); - } - else - { - UpdateFilterData_Category(serie, dataZoom); - } - } - else if (dataZoom.yAxisIndexs.Contains(serie.yAxisIndex)) - { - if (dataZoom.IsYAxisIndexValue(serie.yAxisIndex)) - { - float min = 0, max = 0; - dataZoom.GetYAxisIndexValue(serie.yAxisIndex, out min, out max); - UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max); - } - else - { - UpdateFilterData_Category(serie, dataZoom); - } - } - } - - private static void UpdateFilterData_XAxisValue(Serie serie, DataZoom dataZoom, int dimension, float min, float max) - { - var data = serie.data; - var startValue = min + (max - min) * dataZoom.start / 100; - var endValue = min + (max - min) * dataZoom.end / 100; - if (endValue < startValue) endValue = startValue; - - if (startValue != serie.m_FilterStartValue || endValue != serie.m_FilterEndValue - || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData) - { - serie.m_FilterStartValue = startValue; - serie.m_FilterEndValue = endValue; - serie.m_FilterMinShow = dataZoom.minShowNum; - serie.m_NeedUpdateFilterData = false; - - serie.m_FilterData.Clear(); - foreach (var serieData in data) - { - var value = serieData.GetData(dimension); - if (value >= startValue && value <= endValue) - { - serie.m_FilterData.Add(serieData); - } - } - } - else if (endValue == 0) - { - serie.m_FilterData = emptyFilter; - } - } - - private static void UpdateFilterData_Category(Serie serie, DataZoom dataZoom) - { - var data = serie.data; - var startIndex = (int)((data.Count - 1) * dataZoom.start / 100); - var endIndex = (int)((data.Count - 1) * dataZoom.end / 100); - if (endIndex < startIndex) endIndex = startIndex; - - if (startIndex != serie.m_FilterStart || endIndex != serie.m_FilterEnd - || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData) - { - serie.m_FilterStart = startIndex; - serie.m_FilterEnd = endIndex; - serie.m_FilterMinShow = dataZoom.minShowNum; - serie.m_NeedUpdateFilterData = false; - var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1; - if (count < dataZoom.minShowNum) - { - if (dataZoom.minShowNum > data.Count) count = data.Count; - else count = dataZoom.minShowNum; - } - if (data.Count > 0) - { - if (startIndex + count > data.Count) - { - int start = endIndex - count; - data = data.GetRange(start < 0 ? 0 : start, count); - } - else serie.m_FilterData = data.GetRange(startIndex, count); - } - else - { - serie.m_FilterData = data; - } - } - else if (endIndex == 0) - { - serie.m_FilterData = emptyFilter; - } - } - } -} \ No newline at end of file diff --git a/Runtime/Internal/Helper/SerieHelper.cs.meta b/Runtime/Internal/Helper/SerieHelper.cs.meta deleted file mode 100644 index 1cd082c4..00000000 --- a/Runtime/Internal/Helper/SerieHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e5c421b17fb6f45a283f4f57efce686f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Internal/Helper/VesselHelper.cs b/Runtime/Internal/Helper/VesselHelper.cs index 016de48e..cc0e5ce3 100644 --- a/Runtime/Internal/Helper/VesselHelper.cs +++ b/Runtime/Internal/Helper/VesselHelper.cs @@ -12,7 +12,7 @@ namespace XCharts { public static class VesselHelper { - internal static Color32 GetColor(Vessel vessel, Serie serie, ChartTheme theme, List legendRealShowName) + public static Color32 GetColor(Vessel vessel, Serie serie, ChartTheme theme, List legendRealShowName) { if (serie != null && vessel.autoColor) { @@ -25,7 +25,7 @@ namespace XCharts } } - internal static void UpdateVesselCenter(Vessel vessel, Vector3 chartPosition, float chartWidth, float chartHeight) + public static void UpdateVesselCenter(Vessel vessel, Vector3 chartPosition, float chartWidth, float chartHeight) { if (vessel.center.Length < 2) return; var centerX = vessel.center[0] <= 1 ? chartWidth * vessel.center[0] : vessel.center[0];