From 2a815e54dbbcdfea147407398a5e923901861ead Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 3 Sep 2023 22:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Serie=E7=9A=84totalDataIndex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Serie/Serie.cs | 1 + Runtime/Serie/SerieContext.cs | 1 + Runtime/Serie/SerieHandler.cs | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index f5bc888e..a2d5f6e4 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -1330,6 +1330,7 @@ namespace XCharts.Runtime else m_Data.Add(serieData); serieData.OnAdd(animation); + context.totalDataIndex++; SetVerticesDirty(); dataDirty = true; m_NeedUpdateFilterData = true; diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs index 020e7605..fe642286 100644 --- a/Runtime/Serie/SerieContext.cs +++ b/Runtime/Serie/SerieContext.cs @@ -118,5 +118,6 @@ namespace XCharts.Runtime public Tooltip.Type tooltipType; public Tooltip.Trigger tooltipTrigger; + public int totalDataIndex; } } \ No newline at end of file diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 12079dcc..f2774cfb 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -38,8 +38,7 @@ namespace XCharts.Runtime public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent, - ref List paramList, ref string title) - { } + ref List paramList, ref string title) { } public virtual void OnLegendButtonClick(int index, string legendName, bool show) { } public virtual void OnLegendButtonEnter(int index, string legendName) { } public virtual void OnLegendButtonExit(int index, string legendName) { } @@ -77,7 +76,7 @@ namespace XCharts.Runtime internal override void SetSerie(Serie serie) { - this.serie = (T)serie; + this.serie = (T) serie; this.serie.context.param.serieType = typeof(T); m_NeedInitComponent = true; AnimationStyleHelper.UpdateSerieAnimation(serie); @@ -224,6 +223,7 @@ namespace XCharts.Runtime public override void InitComponent() { m_InitedLabel = false; + serie.context.totalDataIndex = serie.dataCount - 1; InitRoot(); InitSerieLabel(); InitSerieTitle(); @@ -386,7 +386,7 @@ namespace XCharts.Runtime return; } InitRoot(); - var dataAutoColor = (Color)chart.GetLegendRealShowNameColor(serie.legendName); + var dataAutoColor = (Color) chart.GetLegendRealShowNameColor(serie.legendName); m_EndLabel = ChartHelper.AddChartLabel(s_SerieEndLabelObjectName, m_SerieRoot.transform, serie.endLabel, chart.theme.common, "", dataAutoColor, TextAnchor.MiddleLeft); m_EndLabel.SetActive(serie.endLabel.show); @@ -599,7 +599,7 @@ namespace XCharts.Runtime var colorIndex = serie.colorByData ? serieData.index : serie.index; Color32 color, toColor; SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal, false); - return (Color)color; + return (Color) color; } protected void UpdateCoordSerieParams(ref List paramList, ref string title,