修复Legend控制的Serie颜色有时候异常的问题

This commit is contained in:
monitor1394
2019-10-03 09:42:03 +08:00
parent 437f985b45
commit b4a7969b91
9 changed files with 163 additions and 217 deletions

View File

@@ -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>

View File

@@ -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>