I am using oxyplot (C#, windows forms) to graph the logfile of an experiment. The user can enter comments during the test, which are saved with text and timestamp and should be displayed in the plot with the data. I tried using TextAnnotations at first, but the comments can be a bit more wordy and frequent than annotations would allow.
My solution is to make a ScatterPlot and have the comments be single Datapoints, which then display timestamp and text of the comment in the Tracker when hovered over. Right now, I can't get the text to show though.
I created a new class for my datapoints to save the text in, which the ScatterSeries will accept:
public class CommentPoint : IScatterPointProvider
{
public CommentPoint(double x, double y, string text)
{
X = x; Y = y; Text = text;
}
public double X, Y;
public string Text;
public ScatterPoint GetScatterPoint()
{
return new ScatterPoint(X, Y);
}
}
Then, I tried modifying the TrackerFormatString so that it would display text:
Series.TrackerFormatString = "{2}\n{Text}";
But when hovering over the Datapoint, the tracker only displays the timestamp, not the text. I was able to make this work with displaying custom numbers before, but I don't know if a string is possible.
This is what worked with a different series:
Series.TrackerFormatString = "{0}\n{2}\n{Scale:#.00 " + unit + "}";
In which "Scale" was the custom property that I wanted to display. So I guess the question is, is there something I need to add to {Text} to make it work/is displaying text in the tracker even possible?
Edit: I forgot to add, my emergency solution would be to save the comments in the title of the ScatterSeries and make a new Series for every comment, though I would like to avoid that if possible.
I haven't tried, but I'm pretty sure it would work, if you turn Text
into a property. You can only bind to properties, not ordinary class members, and I think there is some binding going on in the background. So try this:
public string Text {get; set;}
It would make it very much like the example here.