mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
修复Legend控制的Serie颜色有时候异常的问题
This commit is contained in:
@@ -209,6 +209,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
/// <summary>
|
||||
/// 图例名称。当系列名称不为空时,图例名称即为系列名称;反之则为索引index。
|
||||
/// </summary>
|
||||
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
|
||||
/// <summary>
|
||||
/// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other.
|
||||
/// 数据堆叠,同个类目轴上系列配置相同的stack值后,后一个系列的值会在前一个系列的值上相加。
|
||||
/// </summary>
|
||||
|
||||
@@ -793,18 +793,27 @@ namespace XCharts
|
||||
public List<string> GetSerieNameList()
|
||||
{
|
||||
serieNameList.Clear();
|
||||
foreach (var serie in m_Series)
|
||||
for (int n = 0; n < m_Series.Count; n++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(serie.name) && !serieNameList.Contains(serie.name))
|
||||
var serie = m_Series[n];
|
||||
switch (serie.type)
|
||||
{
|
||||
serieNameList.Add(serie.name);
|
||||
}
|
||||
foreach (var data in serie.data)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(data.name) && !serieNameList.Contains(data.name))
|
||||
{
|
||||
serieNameList.Add(data.name);
|
||||
}
|
||||
case SerieType.Pie:
|
||||
case SerieType.Radar:
|
||||
for (int i = 0; i < serie.data.Count; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(serie.data[i].name))
|
||||
serieNameList.Add(ChartCached.IntToStr(i));
|
||||
else if (!serieNameList.Contains(serie.data[i].name))
|
||||
serieNameList.Add(serie.data[i].name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (string.IsNullOrEmpty(serie.name))
|
||||
serieNameList.Add(ChartCached.IntToStr(n));
|
||||
else if (!serieNameList.Contains(serie.name))
|
||||
serieNameList.Add(serie.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return serieNameList;
|
||||
@@ -871,6 +880,16 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLegalLegendName(string name)
|
||||
{
|
||||
int numName = -1;
|
||||
if (int.TryParse(name, out numName))
|
||||
{
|
||||
if (numName >= 0 && numName < list.Count) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json中解析数据
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user