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

Chartview Trackball text format

1 Answer 151 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Pinou
Top achievements
Rank 2
Pinou asked on 05 Sep 2013, 07:47 AM
Hi,

I'm currently working with implementing new chartview in winform application.
I activate the trackball to show informations like in this sample 
http://www.telerik.com/help/winforms/chartview-features-trackball.html

In this sample, informations are displayed in color, each on a new line and with the LineSeries name.

X - 3: 23
Y - 3: 7

But when I copy the same code in my solution, I view
"X 23 Y 7"

Is there an option to set the default text format ?
If not, do you have sample for using TextNeeded event to build this text formated with axes information ?

Thanks

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 10 Sep 2013, 07:42 AM
Hello Frédéric,

Thank you for contacting us.

I have logged this in our Public Issue Tracking System. You can find it at this address - http://www.telerik.com/support/pits.aspx#/public/winforms/15705.

As a temporary workaround, you can use this class:
public class MyTrackBallController : ChartTrackballController
{
    protected override string GetTrackballText(List<DataPointInfo> points)
    {
        StringBuilder result = new StringBuilder("<html>");
 
        SortedDictionary<Telerik.WinControls.UI.ChartSeries, List<DataPoint>> visiblePoints
            = new SortedDictionary<Telerik.WinControls.UI.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 (Telerik.WinControls.UI.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<Telerik.WinControls.UI.ChartSeries>
    {
        public int Compare(Telerik.WinControls.UI.ChartSeries x, Telerik.WinControls.UI.ChartSeries y)
        {
            if (!(x is IndicatorBase) && y is IndicatorBase)
            {
                return -1;
            }
            else if (x is IndicatorBase && !(y is IndicatorBase))
            {
                return 1;
            }
 
            if (x.Equals(y))
            {
                return 0;
            }
 
            return 1;
        }
    }
 
}

Your Telerik Points were updated for the report.

I hope this will be of your help.
 
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 >>
Tags
ChartView
Asked by
Pinou
Top achievements
Rank 2
Answers by
George
Telerik team
Share this question
or