diff --git a/Documentation/XChartsAPI.md b/Documentation/XChartsAPI.md
index cf2fe4ae..f61b299f 100644
--- a/Documentation/XChartsAPI.md
+++ b/Documentation/XChartsAPI.md
@@ -84,8 +84,12 @@
* `CoordinateChart.ClearAxisData()`:清除所有x轴和y轴的类目数据。
* `CoordinateChart.AddXAxisData(string category, int xAxisIndex = 0)`:添加一个类目数据到指定的 `X` 轴。
* `CoordinateChart.AddYAxisData(string category, int yAxisIndex = 0)`:添加一个类目数据到指定的 `Y` 轴。
-* `CoordinateChart.AddXAxisIcon(Sprite icon, int xAxisIndex = 0)`:添加一个类目数据到指定的 `X` 轴。
-* `CoordinateChart.AddYAxisIcon(Sprite icon, int yAxisIndex = 0)`:添加一个类目数据到指定的 `Y` 轴。。
+* `CoordinateChart.AddXAxisIcon(Sprite icon, int xAxisIndex = 0)`:添加一个图标到指定的 `X` 轴。
+* `CoordinateChart.AddYAxisIcon(Sprite icon, int yAxisIndex = 0)`:添加一个图标到指定的 `Y` 轴。
+* `CoordinateChart.UpdateXAxisData(int index, string category, int xAxisIndex = 0)`:更新 `X` 轴的类目数据。
+* `CoordinateChart.UpdateYAxisData(int index, string category, int yAxisIndex = 0)`:更新 `Y` 轴的类目数据。
+* `CoordinateChart.UpdateXAxisIcon(int index, Sprite icon, int xAxisIndex = 0)`:更新 `X` 轴的图标。
+* `CoordinateChart.UpdateYAxisIcon(int index, Sprite icon, int yAxisIndex = 0)`:更新 `Y` 轴的图标。
* `CoordinateChart.IsValue()`:是否是纯数值坐标。
* `CoordinateChart.RefreshDataZoom()`:在下一帧刷新DataZoom组件。
diff --git a/Runtime/API/CoordinateChart_API.cs b/Runtime/API/CoordinateChart_API.cs
index 64794a22..9e722170 100644
--- a/Runtime/API/CoordinateChart_API.cs
+++ b/Runtime/API/CoordinateChart_API.cs
@@ -107,6 +107,22 @@ namespace XCharts
}
}
+ ///
+ /// Update category data.
+ /// 更新X轴类目数据。
+ ///
+ /// the index of category data
+ ///
+ /// which xAxis index to update to
+ public void UpdateXAxisData(int index, string category, int xAxisIndex = 0)
+ {
+ var xAxis = GetXAxis(xAxisIndex);
+ if (xAxis != null)
+ {
+ xAxis.UpdateData(index, category);
+ }
+ }
+
///
/// Add an icon to xAxis.
/// 添加一个图标到指定的x轴。
@@ -122,6 +138,22 @@ namespace XCharts
}
}
+ ///
+ /// Update xAxis icon.
+ /// 更新X轴图标。
+ ///
+ ///
+ ///
+ ///
+ public void UdpateXAxisIcon(int index, Sprite icon, int xAxisIndex = 0)
+ {
+ var xAxis = GetXAxis(xAxisIndex);
+ if (xAxis != null)
+ {
+ xAxis.UpdateIcon(index, icon);
+ }
+ }
+
///
/// Add a category data to yAxis.
/// 添加一个类目数据到指定的y轴。
@@ -137,6 +169,22 @@ namespace XCharts
}
}
+ ///
+ /// Update category data.
+ /// 更新Y轴类目数据。
+ ///
+ /// the index of category data
+ ///
+ /// which yAxis index to update to
+ public void UpdateYAxisData(int index, string category, int yAxisIndex = 0)
+ {
+ var yAxis = GetYAxis(yAxisIndex);
+ if (yAxis != null)
+ {
+ yAxis.UpdateData(index, category);
+ }
+ }
+
///
/// Add an icon to yAxis.
/// 添加一个图标到指定的y轴。
@@ -152,6 +200,21 @@ namespace XCharts
}
}
+ ///
+ /// 更新Y轴图标。
+ ///
+ ///
+ ///
+ ///
+ public void UpdateYAxisIcon(int index, Sprite icon, int yAxisIndex = 0)
+ {
+ var yAxis = GetYAxis(yAxisIndex);
+ if (yAxis != null)
+ {
+ yAxis.UpdateIcon(index, icon);
+ }
+ }
+
///
/// reutrn true when all the show axis is `Value` type.
/// 纯数值坐标轴(数值轴或对数轴)。
diff --git a/Runtime/Component/Main/Axis.cs b/Runtime/Component/Main/Axis.cs
index 59a9e197..07a7a348 100644
--- a/Runtime/Component/Main/Axis.cs
+++ b/Runtime/Component/Main/Axis.cs
@@ -586,6 +586,24 @@ namespace XCharts
SetAllDirty();
}
+ ///
+ /// 更新类目数据
+ ///
+ ///
+ ///
+ public void UpdateData(int index, string category)
+ {
+ if (index >= 0 && index < m_Data.Count)
+ {
+ m_Data[index] = category;
+ SetComponentDirty();
+ }
+ }
+
+ ///
+ /// 添加图标
+ ///
+ ///
public void AddIcon(Sprite icon)
{
if (maxCache > 0)
@@ -600,6 +618,20 @@ namespace XCharts
SetAllDirty();
}
+ ///
+ /// 更新图标
+ ///
+ ///
+ ///
+ public void UpdateIcon(int index, Sprite icon)
+ {
+ if (index >= 0 && index < m_Icons.Count)
+ {
+ m_Icons[index] = icon;
+ SetComponentDirty();
+ }
+ }
+
///
/// 获得指定索引的类目数据
///