mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 15:30:09 +00:00
优化和完善数据更新UpdateData接口
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2019.12.03) 增加圆环饼图的圆角支持
|
||||
* (2019.12.03) 增加数据更新动画
|
||||
* (2019.12.04) 优化和完善数据更新`UpdateData`接口
|
||||
* (2019.12.03) 增加圆环饼图的圆角支持,参数:`serie.arcShaped`
|
||||
* (2019.12.03) 增加数据更新动画,参数:`serie.animation.updateAnimation`
|
||||
* (2019.11.30) 增加`GaugeChart`仪表盘
|
||||
* (2019.11.22) 修复`BarChart`清空数据重新赋值后`SerieLabel`显示异常的问题
|
||||
* (2019.11.16) 修复`SerieLabel`设置`color`等参数不生效的问题
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
* `BaseChart.AddData(int serieIndex, float xValue, float yValue, string dataName = null)`:添加`(x,y)`数据到指定系列中。
|
||||
* `BaseChart.UpdateData(string serieName,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
||||
* `BaseChart.UpdateData(int serieIndex,int dataIndex, float value)`:更新指定系列中的指定索引数据。
|
||||
* `BaseChart.UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
|
||||
* `BaseChart.UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)`:更新指定系列指定索引的数据项的多维数据。
|
||||
* `BaseChart.UpdateData(string serieName, int dataIndex, int dimension, float value)`:更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||
* `BaseChart.UpdateData(int serieIndex, int dataIndex, int dimension, float value)`:更新指定系列指定索引指定维数的数据。维数从0开始。
|
||||
* `BaseChart.UpdateDataName(string serieName,int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
||||
* `BaseChart.UpdateDataName(int serieIndex, int dataIndex, string dataName)`:更新指定系列中的指定索引数据名称。
|
||||
* `BaseChart.SetActive(string serieName, bool active)`:设置指定系列是否显示。
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
[QA 21:如何显示图例?](#如何显示图例)
|
||||
[QA 22:如何做成预设?](#如何做成预设)
|
||||
[QA 23:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
||||
[QA 24:如何实现心电图类似的数据移动效果?](#如何实现心电图类似的数据移动效果)
|
||||
|
||||
## 如何调整坐标轴与背景的边距
|
||||
|
||||
@@ -120,6 +121,10 @@
|
||||
|
||||
答:xcharts有自定义绘制回调`customDrawCallback`,具体可参考`Demo12_CustomDrawing.cs`
|
||||
|
||||
## 如何实现心电图类似的数据移动效果
|
||||
|
||||
答:axis和serie都设置相同的maxCache。maxCache可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
||||
|
||||
[返回首页](https://github.com/monitor1394/unity-ugui-XCharts)
|
||||
[XChartsAPI接口](XChartsAPI.md)
|
||||
[XCharts配置项手册](XCharts配置项手册.md)
|
||||
|
||||
@@ -258,10 +258,14 @@ namespace XCharts
|
||||
/// <param name="serieName">the name of serie</param>
|
||||
/// <param name="dataIndex">the index of data</param>
|
||||
/// <param name="value">the data will be update</param>
|
||||
public virtual void UpdateData(string serieName, int dataIndex, float value)
|
||||
public virtual bool UpdateData(string serieName, int dataIndex, float value)
|
||||
{
|
||||
m_Series.UpdateData(serieName, dataIndex, value);
|
||||
RefreshChart();
|
||||
if (m_Series.UpdateData(serieName, dataIndex, value))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -271,10 +275,46 @@ namespace XCharts
|
||||
/// <param name="serieIndex">the index of serie</param>
|
||||
/// <param name="dataIndex">the index of data</param>
|
||||
/// <param name="value">the data will be update</param>
|
||||
public virtual void UpdateData(int serieIndex, int dataIndex, float value)
|
||||
public virtual bool UpdateData(int serieIndex, int dataIndex, float value)
|
||||
{
|
||||
m_Series.UpdateData(serieIndex, dataIndex, value);
|
||||
RefreshChart();
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, value))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列指定索引的数据项的多维数据。
|
||||
/// </summary>
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
|
||||
public virtual bool UpdateData(string serieName, int dataIndex, List<float> multidimensionalData)
|
||||
{
|
||||
if (m_Series.UpdateData(serieName, dataIndex, multidimensionalData))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定系列指定索引的数据项的多维数据。
|
||||
/// </summary>
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="multidimensionalData">一个数据项的多维数据列表,而不是多个数据项的数据</param>
|
||||
public virtual bool UpdateData(int serieIndex, int dataIndex, List<float> multidimensionalData)
|
||||
{
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, multidimensionalData))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -284,10 +324,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dimension">指定维数,从0开始</param>
|
||||
/// <param name="value"></param>
|
||||
public virtual void UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||
public virtual bool UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||
{
|
||||
m_Series.UpdateData(serieName, dataIndex, dimension, value);
|
||||
RefreshChart();
|
||||
if (m_Series.UpdateData(serieName, dataIndex, dimension, value))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -297,10 +341,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dimension">指定维数,从0开始</param>
|
||||
/// <param name="value"></param>
|
||||
public virtual void UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||
public virtual bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||
{
|
||||
m_Series.UpdateData(serieIndex, dataIndex, dimension, value);
|
||||
RefreshChart();
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, dimension, value))
|
||||
{
|
||||
RefreshChart();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -310,9 +358,9 @@ namespace XCharts
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dataName"></param>
|
||||
public virtual void UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||
public virtual bool UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||
{
|
||||
m_Series.UpdateDataName(serieName, dataIndex, dataName);
|
||||
return m_Series.UpdateDataName(serieName, dataIndex, dataName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -322,9 +370,9 @@ namespace XCharts
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public virtual void UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||
public virtual bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||
{
|
||||
m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
|
||||
return m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -494,7 +494,11 @@ namespace XCharts
|
||||
/// 标题样式。
|
||||
/// </summary>
|
||||
public TitleStyle titleStyle { get { return m_TitleStyle; } set { m_TitleStyle = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// 数据项里的数据维数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int showDataDimension { get { return m_ShowDataDimension; } }
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
@@ -991,9 +995,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="value"></param>
|
||||
public void UpdateYData(int index, float value)
|
||||
public bool UpdateYData(int index, float value)
|
||||
{
|
||||
UpdateData(index, 1, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1002,10 +1007,11 @@ namespace XCharts
|
||||
/// <param name="index"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
public void UpdateXYData(int index, float xValue, float yValue)
|
||||
public bool UpdateXYData(int index, float xValue, float yValue)
|
||||
{
|
||||
UpdateData(index, 0, xValue);
|
||||
UpdateData(index, 1, yValue);
|
||||
var flag1 = UpdateData(index, 0, xValue);
|
||||
var flag2 = UpdateData(index, 1, yValue);
|
||||
return flag1 || flag2;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1014,16 +1020,36 @@ namespace XCharts
|
||||
/// <param name="index">要更新数据的索引</param>
|
||||
/// <param name="dimension">要更新数据的维数</param>
|
||||
/// <param name="value">新的数据值</param>
|
||||
public void UpdateData(int index, int dimension, float value)
|
||||
public bool UpdateData(int index, int dimension, float value)
|
||||
{
|
||||
if (index < 0) return;
|
||||
if (index < m_Data.Count)
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
{
|
||||
m_Data[index].UpdateData(dimension, value);
|
||||
return m_Data[index].UpdateData(dimension, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDataName(int index, string name)
|
||||
/// <summary>
|
||||
/// 更新指定索引的数据项数据列表
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="values"></param>
|
||||
public bool UpdateData(int index, List<float> values)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count && values != null)
|
||||
{
|
||||
var list = m_Data[index].data;
|
||||
list.Clear();
|
||||
foreach (var v in values) list.Add(v);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateDataName(int index, string name)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
{
|
||||
@@ -1033,7 +1059,9 @@ namespace XCharts
|
||||
{
|
||||
serieData.labelText.text = name == null ? "" : name;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -394,13 +394,14 @@ namespace XCharts
|
||||
/// <param name="name"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
public void UpdateData(string serieName, int dataIndex, float value)
|
||||
public bool UpdateData(string serieName, int dataIndex, float value)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateYData(dataIndex, value);
|
||||
return serie.UpdateYData(dataIndex, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -409,13 +410,14 @@ namespace XCharts
|
||||
/// <param name="serieName"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dataName"></param>
|
||||
public void UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||
public bool UpdateDataName(string serieName, int dataIndex, string dataName)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateDataName(dataIndex, dataName);
|
||||
return serie.UpdateDataName(dataIndex, dataName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -424,13 +426,14 @@ namespace XCharts
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dataName"></param>
|
||||
public void UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||
public bool UpdateDataName(int serieIndex, int dataIndex, string dataName)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateDataName(dataIndex, dataName);
|
||||
return serie.UpdateDataName(dataIndex, dataName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -439,13 +442,31 @@ namespace XCharts
|
||||
/// <param name="serieIndex"></param>
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="value"></param>
|
||||
public void UpdateData(int serieIndex, int dataIndex, float value)
|
||||
public bool UpdateData(int serieIndex, int dataIndex, float value)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateYData(dataIndex, value);
|
||||
return serie.UpdateYData(dataIndex, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateData(string serieName,int dataIndex,List<float> values){
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
return serie.UpdateData(dataIndex, values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public bool UpdateData(int serieIndex,int dataIndex,List<float> values){
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
return serie.UpdateData(dataIndex, values);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -455,13 +476,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex">数据项</param>
|
||||
/// <param name="dimension">数据维数,从0开始</param>
|
||||
/// <param name="value">值</param>
|
||||
public void UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||
public bool UpdateData(int serieIndex, int dataIndex, int dimension, float value)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateData(dataIndex, dimension, value);
|
||||
return serie.UpdateData(dataIndex, dimension, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -471,13 +493,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="dimension">数据维数,从0开始</param>
|
||||
/// <param name="value"></param>
|
||||
public void UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||
public bool UpdateData(string serieName, int dataIndex, int dimension, float value)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateData(dataIndex, dimension, value);
|
||||
return serie.UpdateData(dataIndex, dimension, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -488,13 +511,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
public void UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
|
||||
public bool UpdateXYData(string serieName, int dataIndex, float xValue, float yValue)
|
||||
{
|
||||
var serie = GetSerie(serieName);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
return serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -504,13 +528,14 @@ namespace XCharts
|
||||
/// <param name="dataIndex"></param>
|
||||
/// <param name="xValue"></param>
|
||||
/// <param name="yValue"></param>
|
||||
public void UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
|
||||
public bool UpdateXYData(int serieIndex, int dataIndex, float xValue, float yValue)
|
||||
{
|
||||
var serie = GetSerie(serieIndex);
|
||||
if (serie != null)
|
||||
{
|
||||
serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
return serie.UpdateXYData(dataIndex, xValue, yValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateData(int dimension, float value)
|
||||
public bool UpdateData(int dimension, float value)
|
||||
{
|
||||
if (dimension >= 0 && dimension < data.Count)
|
||||
{
|
||||
@@ -209,7 +209,9 @@ namespace XCharts
|
||||
m_DataUpdateTime[dimension] = Time.time;
|
||||
m_DataUpdateFlag[dimension] = true;
|
||||
data[dimension] = value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckLastData()
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
public const string version = "1.0.5";
|
||||
public const int date = 20191122;
|
||||
public const int date = 20191204;
|
||||
|
||||
[SerializeField] private string m_NowVersion;
|
||||
[SerializeField] private string m_NewVersion;
|
||||
|
||||
Reference in New Issue
Block a user