| public MainWindow() { InitializeComponent(); textAnnotation1 = new TextAnnotation(); textAnnotation1.CoordinateUnit = CoordinateUnit.Pixel; textAnnotation1.YAxisName = "row1YAxis"; textAnnotation1.Text = "TextAnnotation 1"; chart.Annotations.Add(textAnnotation1); textAnnotation2 = new TextAnnotation(); textAnnotation2.CoordinateUnit = CoordinateUnit.Pixel; textAnnotation2.YAxisName = "row1YAxis"; textAnnotation2.Text = "TextAnnotation 2"; chart.Annotations.Add(textAnnotation2); } private void UpdateAnnotation() { var xPos = chart.ValueToPoint(xAxis, xAxis.VisibleRange.Start)+chart.SeriesClipRect.Left + 10; var yPos = chart.ValueToPoint(row1YAxis, row1YAxis.VisibleRange.End) + 5; textAnnotation1.X1 = xPos; textAnnotation1.Y1 = yPos; textAnnotation2.X1 = xPos; textAnnotation2.Y1 = yPos + 20; } private void chart_ZoomChanged(object sender, ZoomChangedEventArgs e) { UpdateAnnotation(); } private void row1YAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) { UpdateAnnotation(); } private void chart_SizeChanged(object sender, SizeChangedEventArgs e) { UpdateAnnotation(); } private void NumericalAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) { UpdateAnnotation(); } |