mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-31 05:48:45 +00:00
增加数据更新接口UpdateData
This commit is contained in:
@@ -218,6 +218,14 @@ namespace xcharts
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdataData(int index, float value)
|
||||||
|
{
|
||||||
|
if (index >= 0 && index <= dataList.Count - 1)
|
||||||
|
{
|
||||||
|
dataList[index] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseChart : MaskableGraphic
|
public class BaseChart : MaskableGraphic
|
||||||
@@ -277,7 +285,7 @@ namespace xcharts
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < seriesList.Count; i++)
|
for (int i = 0; i < seriesList.Count; i++)
|
||||||
{
|
{
|
||||||
if (seriesList[i].name == legend)
|
if (seriesList[i].name.Equals(legend))
|
||||||
{
|
{
|
||||||
seriesList[i].AddData(value);
|
seriesList[i].AddData(value);
|
||||||
break;
|
break;
|
||||||
@@ -286,6 +294,32 @@ namespace xcharts
|
|||||||
RefreshChart();
|
RefreshChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateData(string legend, float value, int dataIndex = 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < seriesList.Count; i++)
|
||||||
|
{
|
||||||
|
if (seriesList[i].name.Equals(legend))
|
||||||
|
{
|
||||||
|
seriesList[i].UpdataData(dataIndex, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateData(int legendIndex, float value, int dataIndex = 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < seriesList.Count; i++)
|
||||||
|
{
|
||||||
|
if (i == legendIndex)
|
||||||
|
{
|
||||||
|
seriesList[i].UpdataData(dataIndex, value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RefreshChart();
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdateTheme(Theme theme)
|
public void UpdateTheme(Theme theme)
|
||||||
{
|
{
|
||||||
this.theme = theme;
|
this.theme = theme;
|
||||||
@@ -598,4 +632,3 @@ namespace xcharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user