Trackball issue Workaround? (fixed in sp1)

4 posts, 0 answers
  1. Toni
    Toni avatar
    7 posts
    Member since:
    Mar 2013

    Posted 29 Nov 2013 Link to this post

    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
  2. George
    Admin
    George avatar
    500 posts

    Posted 03 Dec 2013 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    1 posts
    Member since:
    Nov 2013

    Posted 30 Jan 2014 in reply to George Link to this post

    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
  5. George
    Admin
    George avatar
    500 posts

    Posted 04 Feb 2014 Link to this post

    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 >>
Back to Top