This is a migrated thread and some comments may be shown as answers.

Trackball issue Workaround? (fixed in sp1)

3 Answers 29 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Toni
Top achievements
Rank 2
Toni asked on 29 Nov 2013, 09:17 AM
Hey,

We are kinda in problems with chartview's trackball issue. Every time we swap our serie's CombineMode and move mouse over chart, our program crashes. We are still running with Q3 -version (can't rush SP1 update as we have to pre-plan these ones). We have allready tested that in SP1 issue is fixed, as you have reported in release notes.

Do you happen to have any workaround for Q3's trackball issue, so that we could keep running with current version for couple more months?


Best Regards,
Toni Hämeenniemi

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 03 Dec 2013, 04:11 PM
Hi Toni,

Thank you for contacting us.

Yes, there is a workaround for this issue. You need to create 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());
        }
    }
}

You can use this controller as follows:
for (int i = 0; i < this.radChartView1.Controllers.Count; i++)
{
    if (this.radChartView1.Controllers[i] is ChartTrackballController)
    {
        this.radChartView1.Controllers.RemoveAt(i);
        this.radChartView1.Controllers.Add(new MyChartTrackballController());
        break;
    }
}

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Michael
Top achievements
Rank 1
answered on 30 Jan 2014, 04:18 PM
Looking at this example, what if I wanted to display the X axis value for the points being displayed in the TrackBallInfo Element.

The GetPointText method returns the text value as a string for the point it is passed, but only the Y coordinate.

result.AppendFormat("<color={0}>{1}", color,this.GetPointText(visiblePoints[series][i]));


What if I wanted the X coordinate value too? either as a double or as a string or whatever.

Thanks

Michael
0
George
Telerik team
answered on 04 Feb 2014, 12:32 PM
Hello Michael,

Thank you for replying.

You can use the TrackBallPointTextNeeded event of the ChartSeries. For example, if you have AreaSeries:
foreach (Telerik.WinControls.UI.AreaSeries series in this.chart.Series)
{
    series.TrackballPointTextNeeded += series_TrackballPointTextNeeded;
}
 
void series_TrackballPointTextNeeded(object sender, TrackballPointTextNeededEventArgs e)
{
    e.Text = string.Format(" {0}", ((CategoricalDataPoint)e.Point).Category);
}

I hope this helps.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Toni
Top achievements
Rank 2
Answers by
George
Telerik team
Michael
Top achievements
Rank 1
Share this question
or