Under review

TrackerFormatString question

Oystein Bjorke 10 years ago updated by anonymous 10 years ago 3
This discussion was imported from CodePlex

seveland12 wrote at 2012-06-04 19:11:

In the documentation page

http://oxyplot.codeplex.com/wikipage?title=Custom%20trackers&referringTitle=Documentation

it states that you can define what the tracker displays by modifying the TrackerFormatString property of the series. What format is this property expecting? In particular, if I want my tracker to show the following:

 

X Axis Title: 0.###

Y Axis Title: 0.###

 

(where 0.### is meant to be the appropriate value to 3 decimal places), what do I have to set TrackerFormatString to? I'm using LineSeries and ScatterSeries, if that makes a difference.

 

Thanks,

 

Steve


objo wrote at 2012-06-04 22:09:

Sorry the wiki documentation is not finished. 

The tracker format string has some variations for different series (should be documented... and maybe improved?), but it should at least support the following arguments

{0} the title of the series
{1} the title of the x-axis
{2} the x-value
{3} the title of the y-axis
{4} the y-value

For ScatterSeries you also have

{5} the title of the value-axis
{6} the value of the scatter point

This means that in your case you should be able to use

X Axis Title: {2:0.###}
Y Axis Title: {4:0.###}

The format string can also contain names of properties of the items (requires use of the ItemsSource property):

{X:0.###}, {Y:0.###}, {Value:0.###}

where X, Y and Value are properties of your items.


_Noctis_ wrote at 2013-10-21 10:20:

Just in case it helps anyone, and expanding on the above:

If you have a class like this:
class ExercisePoint : IDataPoint
    {
        public double X { get; set; }
        public double Y { get; set; }
        public int Lvl { get; set; }
        public DateTime DateTime { get; set; }
        public string Exercise { get; set; }
    }
You could then create a line series with a custom Tracker that look like this:
var line_series_array = new LineSeries()
                {
                    ... other propreties initialization here ...

                    TrackerFormatString = "{DateTime:dd.MM.yy}"+ Environment.NewLine +"{Exercise}, lvl {Lvl}:{Y}"
                };
This will give you in this case, the date in the given format on one line, and on the second, the exercise, level, and Y value.

Easy peasy once you figure it out ... :)


(Just wondering, any chance of being able to format the text in there? )

oloopy wrote at 2014-04-11 11:19:

Thanks for the post.

An additional tip here. The default setting is like below,
var lineSeries = new LineSeries
{
    TrackerFormatString = "{0} " + Environment.NewLine + "{1}: {2} " + Environment.NewLine + "{3}: {4} ",
}
You can modify it based on that. Also note that the {0} would be used in Legend Title.

Archer25 wrote at 2014-04-30 07:55:

Hello i need help
Ihave a scatterSeries. And i need to for every point's have unique string lines, and this lines must show at the tracker.
How i can do that???
Image
What format string do I need to format DateTime like "yyyy-MM-dd HH:mm"?

For example for line series of DataPoint I code
TrackerFormatString = "{0}\nTime: {X:???}\nValue: {Y:0.0000}";
X - time axis
It seems I used names of properties incorrectly... This works as expected:
TrackerFormatString = "{0}\nTime: {2:yyyy-MM-dd HH:mm}\nValue: {4:0.0000}";
Under review
I have started updating information about the TrackerFormatString, for LineSeries, see http://oxyplot.org/documentation/series/LineSeries