Approved
Last Updated: 29 Mar 2016 11:04 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 10 Mar 2016 07:52
Category: ChartView
Type: Bug Report
1
FIX. RadChartView - ChartTrackballController shows the labels in a random order
To reproduce:

BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
barSeries.Name = "Q1";
barSeries.CombineMode = ChartSeriesCombineMode.Stack;
barSeries.DataPoints.Add(new CategoricalDataPoint(177, "Harley"));
barSeries.DataPoints.Add(new CategoricalDataPoint(128, "White"));
barSeries.DataPoints.Add(new CategoricalDataPoint(143, "Smith"));
barSeries.DataPoints.Add(new CategoricalDataPoint(111, "Jones")); 
barSeries.DataPoints.Add(new CategoricalDataPoint(118, "Marshall"));
this.radChartView1.Series.Add(barSeries);
BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
barSeries2.Name = "Q2";
barSeries2.CombineMode = ChartSeriesCombineMode.Stack;
barSeries2.DataPoints.Add(new CategoricalDataPoint(153, "Harley"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(141, "White"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(130, "Smith"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(88, "Jones"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(109, "Marshall"));
this.radChartView1.Series.Add(barSeries2);
BarSeries barSeries3 = new BarSeries("Performance", "RepresentativeName");
barSeries3.Name = "Q3";
barSeries3.CombineMode = ChartSeriesCombineMode.Stack;
barSeries3.DataPoints.Add(new CategoricalDataPoint(153, "Harley"));
barSeries3.DataPoints.Add(new CategoricalDataPoint(141, "White"));
barSeries3.DataPoints.Add(new CategoricalDataPoint(130, "Smith"));
barSeries3.DataPoints.Add(new CategoricalDataPoint(88, "Jones"));
barSeries3.DataPoints.Add(new CategoricalDataPoint(109, "Marshall"));
this.radChartView1.Series.Add(barSeries3);

this.radChartView1.ShowTrackBall = true;

Note: the trackball labels should be displayed in the order the series are displayed in the chart view.

Workaround:

private void ChartTrackballController_TextNeeded(object sender, TextNeededEventArgs e)
{
    string pattern = " \\d+.?\\d* ";
    StringBuilder sb = new StringBuilder("<html>");
    List<DataPointInfo> points = new List<DataPointInfo>();
    foreach (DataPointInfo dp in e.Points)
    {
        points.Add(dp);
    }
    points.Reverse();
    foreach (DataPointInfo dp in points)
    {
        Color pointColor = this.GetColorForDataPoint(dp.Series, dp.DataPoint);
        string color = string.Format("{0},{1},{2},{3}", pointColor.A, pointColor.R, pointColor.G, pointColor.B);
        sb.AppendFormat("<color={0}>{1}", color, string.Format("{0} {1}", dp.Series.Name, ((CategoricalDataPoint)dp.DataPoint).Value));
        sb.AppendLine();
    }

    e.Text = sb.ToString();
}

protected virtual Color GetColorForDataPoint(ChartSeries series, DataPoint point)
{
    if (series is IndicatorBase)
    {
        return series.BorderColor;
    }

    foreach (UIChartElement element in series.Children)
    {
        DataPointElement pointElement = element as DataPointElement;

        if (pointElement != null)
        {
            if (pointElement.DataPoint.Equals(point))
            {
                if (pointElement.BackColor.A > 0)
                {
                    return pointElement.BackColor;
                }
                else
                {
                    return pointElement.BorderColor;
                }
            }
        }
    }

    return Color.Black;
}
Attached Files:
0 comments