SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
I have bound the annotation collection to the scichart as shown below.
Annotations="{s:AnnotationsBinding ChartAnnotations}"
And in the code behind (view model) i am adding annotations to the collection like,
private AnnotationCollection _ChartAnnotations = new AnnotationCollection();
public AnnotationCollection ChartAnnotations
{
get { return _ChartAnnotations; }
set
{
if (_ChartAnnotations == value)
return;
_ChartAnnotations = value;
OnPropertyChanged("ChartAnnotations");
}
}
TextAnnotation annotation = new TextAnnotation();
annotation.X1 = FirstX;
annotation.Y1 = 2.0;
annotation.Text = tempData1[(i - 1) >= 0 ? (i - 1) : 0].PacketType.ToString();
ChartAnnotations.Add(annotation);
But I am not getting any annotation when I run it, moreover, the original scichart series is also getting disturbed.
Would be grateful if you look into the issue.
Thanks
Hi there,
Thank you for your question!
The AnnotationsBinding Markup Extension must be bound to a collection of IAnnotationViewModel
Like this:
<s:SciChartSurface Annotations="{s:AnnotationsBinding Annotations}">
</s:SciChartSurface>
…
public class MainViewModel : BindableObject
{
private ObservableCollection<IAnnotationViewModel> _annotations = new ObservableCollection<IAnnotationViewModel>();
public MainViewModel()
{
Annotations.Add(new LineAnnotationViewModel()
{
X1 = 1, X2 = 2, Y1 = 1, Y2 = 2,
XAxisId = AxisBase.DefaultAxisId,
YAxisId = AxisBase.DefaultAxisId,
CoordinateMode = AnnotationCoordinateMode.Relative,
DragDirections = XyDirection.XYDirection,
ResizeDirections = XyDirection.XYDirection,
StrokeThickness = 2,
Stroke = Colors.Red,
});
...
}
public ObservableCollection<IAnnotationViewModel> Annotations { get { return _annotations; } }
}
Please see our Annotations MVVM API Documentation for more details.
Best regards,
Andrew
Please login first to submit.