0
Under review
Linking data series and annotations
Hello.. I am trying to place textual information above particular points in the series, and have them be linked, meaning that if I scroll around the plot, the text is always in the same position relative to a particular point in the series. like so:
my lets say length of my int[] data is 15 and it contains values {22, 44, 55, 87, 33, 21, 23, 44, 33, 42, 54, 56, 66, 77, 99}
I need to place letter "H" over position 3, "Z" over position 8, and "T" over position 12. All annotations are near the top of the plot area. My code works fine displaying regular LineSeries but I cant figure out how to add the annotations. Any help is appreciated
my lets say length of my int[] data is 15 and it contains values {22, 44, 55, 87, 33, 21, 23, 44, 33, 42, 54, 56, 66, 77, 99}
I need to place letter "H" over position 3, "Z" over position 8, and "T" over position 12. All annotations are near the top of the plot area. My code works fine displaying regular LineSeries but I cant figure out how to add the annotations. Any help is appreciated
public void SetWaveformData(int[] data)
{
PlotModel plotModel = new PlotModel();
List<DataPoint> dataSeries = new List<DataPoint>();
int i = 0;
foreach (int yValue in data)
{
dataSeries.Add(new DataPoint { X = i++, Y = yValue });
}
LineSeries ser = new LineSeries();
ser.Points.AddRange(dataSeries);
plotModel.Series.Add(ser);
}
Customer support service by UserEcho
1. use TextAnnotations for the H,Z and T labels
2. use the labelling feature for the LineSeries. Create a new point type that also includes a property that returns "H","Z","T" or null. Bind the points to the ItemsSource on the LineSeries, and set the format string for the labels to use the property just mentioned. I am not sure if this works right now, but it should be easy to fix!
How does one "set the format string for the labels to use the property just mentioned."
I created a class called AnnotatedDataPoint from IDataPointProvider, implemented DataPoint GetDataPoint() and added a property called Label with getter and setter. default value is null, just like you said.
Then I created a List<AnnotatedDataPoint> and populated it with data and assigned proper labels to some datapoints.
It displays waveform if I do this
which tells me that I implemented my AnnotatedDataPoint correctly, but from here how do I actually assign the "Label" property to format string? Again, help is much appreciated.
ps. It would be great to have this added as an example in the example library!