diff --git a/Examples/Example_Test.cs b/Examples/Example_Test.cs index f105bc79..e51b0ac9 100644 --- a/Examples/Example_Test.cs +++ b/Examples/Example_Test.cs @@ -51,15 +51,9 @@ namespace XCharts.Example void AddData() { - chart.ClearData(); - int count = Random.Range(5, 100); - for (int i = 0; i < count; i++) - { - chart.AddXAxisData("x" + i); - if (Random.Range(1, 3) == 2) - chart.AddData(0, Random.Range(-110, 200)); - else - chart.AddData(0, Random.Range(-100, 100)); + var serie = chart.InsertSerie(0); + for(int i=0;i<5;i++){ + chart.AddData(serie.index, Random.Range(10,90)); } } } diff --git a/Runtime/Internal/BaseChart.Serie.cs b/Runtime/Internal/BaseChart.Serie.cs index 9867b5db..48f753ce 100644 --- a/Runtime/Internal/BaseChart.Serie.cs +++ b/Runtime/Internal/BaseChart.Serie.cs @@ -19,7 +19,9 @@ namespace XCharts.Runtime public T InsertSerie(int index, string serieName = null, bool show = true) where T : Serie { if (!CanAddSerie()) return null; - return InsertSerie(index, typeof(T), serieName, show) as T; + var serie = InsertSerie(index, typeof(T), serieName, show) as T; + InitSerieHandlers(); + return serie; } public void InsertSerie(Serie serie, int index = -1, bool addToHead = false) @@ -30,9 +32,7 @@ namespace XCharts.Runtime else if (index >= 0) m_Series.Insert(index, serie); else m_Series.Add(serie); ResetSeriesIndex(); - InitSerieHandlers(); SeriesHelper.UpdateSerieNameList(this, ref m_LegendRealShowName); - RefreshChart(); } public bool MoveUpSerie(int serieIndex)