To reproduce:
Add a RadChartView and add some LineSeries and data points. Set the ShowTrackBall property to true. In some cases KeyNotFound exception occurs.
Workaround:
Use the following class:
public class MyController : ChartTrackballController
{
protected override string GetTrackballText(List<DataPointInfo> points)
{
StringBuilder result = new StringBuilder("<html>");
SortedDictionary<ChartSeries, List<DataPoint>> visiblePoints = new SortedDictionary<ChartSeries, List<DataPoint>>(new ChartSeriesComparer());
foreach (DataPointInfo pointInfo in points)
{
if (visiblePoints.ContainsKey(pointInfo.Series))
{
visiblePoints[pointInfo.Series].Add(pointInfo.DataPoint);
}
else
{
visiblePoints.Add(pointInfo.Series, new List<DataPoint>() { pointInfo.DataPoint });
}
}
int counter = 0;
foreach (ChartSeries series in visiblePoints.Keys)
{
for (int i = 0; i < visiblePoints[series].Count; i++)
{
Color pointColor = this.GetColorForDataPoint(series, visiblePoints[series][i]);
string color = string.Format("{0},{1},{2},{3}", pointColor.A, pointColor.R, pointColor.G, pointColor.B);
result.AppendFormat("<color={0}>{1}", color, this.GetPointText(visiblePoints[series][i]));
if (i < visiblePoints[series].Count)
{
result.Append(" ");
}
}
counter++;
if (counter < visiblePoints.Keys.Count)
{
result.Append("\n");
}
}
result.Append("</html>");
return result.ToString();
}
class ChartSeriesComparer : IComparer<ChartSeries>
{
public ChartSeriesComparer()
{
}
public int Compare(ChartSeries x, ChartSeries y)
{
if (!(x is IndicatorBase) && y is IndicatorBase)
{
return -1;
}
else if (x is IndicatorBase && !(y is IndicatorBase))
{
return 1;
}
return x.GetHashCode().CompareTo(y.GetHashCode());
}
}
}
Replace the old controller as follows:
for (int i = 0; i < this.radChartView1.Controllers.Count; i++)
{
if (this.radChartView1.Controllers[i] is ChartTrackballController)
{
this.radChartView1.Controllers[i] = new MyController();
break;
}
}
Note that the controller must be replaced before any data is added to the chart