From 990c6dad9072e228a4a28d07ccfb292a76600670 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 15 Aug 2022 08:21:28 +0800 Subject: [PATCH] [API][chart] RemoveAllSerie() --- Documentation/XChartsAPI-EN.md | 5 +++-- Documentation/XChartsAPI-ZH.md | 5 +++-- Runtime/Internal/BaseChart.API.cs | 25 +++++++++++++++++++------ Runtime/Serie/SerieHandler.cs | 2 +- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Documentation/XChartsAPI-EN.md b/Documentation/XChartsAPI-EN.md index 81f8c569..f09576c8 100644 --- a/Documentation/XChartsAPI-EN.md +++ b/Documentation/XChartsAPI-EN.md @@ -176,7 +176,7 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `CanMultipleComponent()` |public bool CanMultipleComponent(Type type)
| | `ClampInChart()` |public void ClampInChart(ref Vector3 pos)
| | `ClampInGrid()` |public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)
| -| `ClearData()` |public virtual void ClearData()
Remove all series and legend data. | +| `ClearData()` |public virtual void ClearData()
Clear all components and series data. Note: serie only empties the data and does not remove serie. | | `ClickLegendButton()` |public void ClickLegendButton(int legendIndex, string legendName, bool show)
点击图例按钮 | | `CovertSerie()` |public bool CovertSerie(Serie serie, Type type)
| | `CovertXYAxis()` |public void CovertXYAxis(int index)
转换X轴和Y轴的配置 | @@ -244,12 +244,13 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `RefreshTopPainter()` |public void RefreshTopPainter()
| | `RefreshUpperPainter()` |public void RefreshUpperPainter()
| | `RemoveAllChartComponent()` |public void RemoveAllChartComponent()
| +| `RemoveAllSerie()` |public virtual void RemoveAllSerie()
Remove all of them Serie. This interface is used when Serie needs to be removed only, and RemoveData() is generally used in other cases. | | `RemoveChartComponent()` |public bool RemoveChartComponent(MainComponent component)
| | `RemoveChartComponent()` |public bool RemoveChartComponent(Type type, int index = 0)
| | `RemoveChartComponent()` |public bool RemoveChartComponent(int index = 0)
| | `RemoveChartComponents()` |public int RemoveChartComponents(Type type)
| | `RemoveChartComponents()` |public int RemoveChartComponents()
| -| `RemoveData()` |public virtual void RemoveData()
Remove all data from series and legend. | +| `RemoveData()` |public virtual void RemoveData()
Empty all component data and remove all series. Use the chart again and again to tell the truth. Note: The component only clears the data part, and the parameters are retained and not reset. | | `RemoveData()` |public virtual void RemoveData(string serieName)
Remove legend and serie by name. | | `RemoveSerie()` |public void RemoveSerie(int serieIndex)
| | `RemoveSerie()` |public void RemoveSerie(Serie serie)
| diff --git a/Documentation/XChartsAPI-ZH.md b/Documentation/XChartsAPI-ZH.md index 02984b29..e2994473 100644 --- a/Documentation/XChartsAPI-ZH.md +++ b/Documentation/XChartsAPI-ZH.md @@ -176,7 +176,7 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `CanMultipleComponent()` |public bool CanMultipleComponent(Type type)
| | `ClampInChart()` |public void ClampInChart(ref Vector3 pos)
| | `ClampInGrid()` |public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)
| -| `ClearData()` |public virtual void ClearData()
It just emptying all of serie's data without emptying the list of series. | +| `ClearData()` |public virtual void ClearData()
清空所有组件和Serie的数据。注意:Serie只是清空数据,不会移除Serie。 | | `ClickLegendButton()` |public void ClickLegendButton(int legendIndex, string legendName, bool show)
点击图例按钮 | | `CovertSerie()` |public bool CovertSerie(Serie serie, Type type)
| | `CovertXYAxis()` |public void CovertXYAxis(int index)
转换X轴和Y轴的配置 | @@ -244,12 +244,13 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver | `RefreshTopPainter()` |public void RefreshTopPainter()
| | `RefreshUpperPainter()` |public void RefreshUpperPainter()
| | `RemoveAllChartComponent()` |public void RemoveAllChartComponent()
| +| `RemoveAllSerie()` |public virtual void RemoveAllSerie()
移除所有的Serie。当确认只需要移除Serie时使用该接口,其他情况下一般用RemoveData()。 | | `RemoveChartComponent()` |public bool RemoveChartComponent(MainComponent component)
| | `RemoveChartComponent()` |public bool RemoveChartComponent(Type type, int index = 0)
| | `RemoveChartComponent()` |public bool RemoveChartComponent(int index = 0)
| | `RemoveChartComponents()` |public int RemoveChartComponents(Type type)
| | `RemoveChartComponents()` |public int RemoveChartComponents()
| -| `RemoveData()` |public virtual void RemoveData()
The series list is also cleared. | +| `RemoveData()` |public virtual void RemoveData()
清空所有组件数据,并移除所有Serie。一般在图表重新初始化时使用。 注意:组件只清空数据部分,参数会保留不会被重置。 | | `RemoveData()` |public virtual void RemoveData(string serieName)
清除指定系列名称的数据。 | | `RemoveSerie()` |public void RemoveSerie(int serieIndex)
| | `RemoveSerie()` |public void RemoveSerie(Serie serie)
| diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index 7c1c2a2b..c0034efb 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -172,9 +172,8 @@ namespace XCharts.Runtime } /// - /// Remove all series and legend data. - /// |It just emptying all of serie's data without emptying the list of series. - /// |清除所有数据,系列中只是移除数据,列表会保留。 + /// Clear all components and series data. Note: serie only empties the data and does not remove serie. + /// |清空所有组件和Serie的数据。注意:Serie只是清空数据,不会移除Serie。 /// public virtual void ClearData() { @@ -187,9 +186,10 @@ namespace XCharts.Runtime } /// - /// Remove all data from series and legend. - /// |The series list is also cleared. - /// |清除所有系列和图例数据,系列的列表也会被清除。 + /// Empty all component data and remove all series. Use the chart again and again to tell the truth. + /// Note: The component only clears the data part, and the parameters are retained and not reset. + /// |清空所有组件数据,并移除所有Serie。一般在图表重新初始化时使用。 + /// 注意:组件只清空数据部分,参数会保留不会被重置。 /// public virtual void RemoveData() { @@ -201,6 +201,19 @@ namespace XCharts.Runtime RefreshChart(); } + /// + /// Remove all of them Serie. This interface is used when Serie needs to be removed only, and RemoveData() is generally used in other cases. + /// |移除所有的Serie。当确认只需要移除Serie时使用该接口,其他情况下一般用RemoveData()。 + /// + [Since("v3.2.0")] + public virtual void RemoveAllSerie() + { + m_Series.Clear(); + m_SerieHandlers.Clear(); + m_CheckAnimation = false; + RefreshChart(); + } + /// /// Remove legend and serie by name. /// |清除指定系列名称的数据。 diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index ef77c1c1..520fe7c6 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -212,12 +212,12 @@ namespace XCharts.Runtime chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); m_SerieLabelRoot.hideFlags = chart.chartHideFlags; SerieLabelPool.ReleaseAll(m_SerieLabelRoot.transform); - //ChartHelper.DestroyAllChildren(m_SerieLabelRoot.transform); int count = 0; SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight); for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; + serieData.index = j; serieData.labelObject = null; if (AddSerieLabel(m_SerieLabelRoot, serieData, ref count)) {