<chart:SfChart.ChartAnnotations> <chart:HorizontalLineAnnotation Y1="100" StrokeWidth="3" > </chart:HorizontalLineAnnotation> <chart:ViewAnnotation x:Name="viewAnnotation" CoordinateUnit="Pixels" > <chart:ViewAnnotation.View> <Entry Text="Editor" /> </chart:ViewAnnotation.View> </chart:ViewAnnotation> </chart:SfChart.ChartAnnotations> |
private void NumericalAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) { if (Device.RuntimePlatform != Device.UWP) { double x1 = chart.ValueToPoint(chart.PrimaryAxis, 0); double y1 = chart.ValueToPoint(chart.SecondaryAxis, 100); if (!double.IsNaN(x1) && !double.IsNaN(y1)) { viewAnnotation.X1 = x1; viewAnnotation.Y1 = y1; } } } |
public class CustomRenderer : SfChartRenderer { protected override void OnElementChanged(ElementChangedEventArgs<SfChart> e) { base.OnElementChanged(e); Control.Series[0].Loaded += Series_Loaded; } private void Series_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { foreach (var annotation in Control.Annotations) { if (annotation is Native.ImageAnnotation) { (annotation as Native.ImageAnnotation).X1 = Control.ValueToPoint(Control.PrimaryAxis, 0.5); (annotation as Native.ImageAnnotation).Y1 = Control.ValueToPoint(Control.SecondaryAxis, 100); (annotation as Native.ImageAnnotation). = Windows.UI.Xaml.VerticalAlignment.Top; } } } } |