修复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

@@ -26,53 +26,5 @@ namespace XCharts
}
}
#endif
protected HashSet<string> m_SerieNameSet = new HashSet<string>();
protected Dictionary<int, List<Serie>> m_StackSeries = new Dictionary<int, List<Serie>>();
protected List<float> m_SeriesCurrHig = new List<float>();
protected override void DrawChart(VertexHelper vh)
{
base.DrawChart(vh);
if (!m_CheckMinMaxValue) return;
bool yCategory = m_YAxises[0].IsCategory() || m_YAxises[1].IsCategory();
m_Series.GetStackSeries(ref m_StackSeries);
int seriesCount = m_StackSeries.Count;
int serieNameCount = -1;
m_SerieNameSet.Clear();
m_BarLastOffset = 0;
for (int j = 0; j < seriesCount; j++)
{
var serieList = m_StackSeries[j];
m_SeriesCurrHig.Clear();
for (int n = 0; n < serieList.Count; n++)
{
Serie serie = serieList[n];
serie.dataPoints.Clear();
if (string.IsNullOrEmpty(serie.name)) serieNameCount++;
else if (!m_SerieNameSet.Contains(serie.name))
{
m_SerieNameSet.Add(serie.name);
serieNameCount++;
}
switch (serie.type)
{
case SerieType.Line:
if (yCategory) DrawYLineSerie(vh, j, serie, ref m_SeriesCurrHig);
else DrawXLineSerie(vh, j, serie, ref m_SeriesCurrHig);
break;
case SerieType.Bar:
if (yCategory) DrawYBarSerie(vh, j, serie, serieNameCount, ref m_SeriesCurrHig);
else DrawXBarSerie(vh, j, serie, serieNameCount, ref m_SeriesCurrHig);
break;
}
}
}
DrawLabelBackground(vh);
DrawLinePoint(vh);
DrawLineArrow(vh);
if (yCategory) DrawYTooltipIndicator(vh);
else DrawXTooltipIndicator(vh);
}
}
}