I have RadCartisianChart on a Window and on a button click I would like to add a vertical line at a particular channel (x-axis value) and label the line. Here is the code for my button click event.
Please let me know if you know why the CartsianCustomAnnotation is now being displayed. I've also provided a link to a zipped stripped-down example C# WPF project which demonstrates this: Telerik ChartView CartesianCusomAnnotation not display
Please let me know if you know why the CartsianCustomAnnotation is now being displayed. I've also provided a link to a zipped stripped-down example C# WPF project which demonstrates this: Telerik ChartView CartesianCusomAnnotation not display
01.
private
void
Button_OnClick(
object
sender, RoutedEventArgs e)
02.
{
03.
Random rnd =
new
Random();
04.
int
curChannel = rnd.Next(1, 1000);
05.
06.
CartesianGridLineAnnotation myLineAnnotation =
new
CartesianGridLineAnnotation();
07.
myLineAnnotation.Axis = radCartesianChart1.HorizontalAxis;
08.
myLineAnnotation.Value = curChannel;
09.
10.
myLineAnnotation.Stroke = System.Windows.Media.Brushes.Fuchsia;
11.
radCartesianChart1.Annotations.Add(myLineAnnotation);
12.
13.
var newKLMLabel =
new
CartesianCustomAnnotation();
14.
newKLMLabel.HorizontalAxis = radCartesianChart1.HorizontalAxis;
15.
newKLMLabel.VerticalAxis = radCartesianChart1.VerticalAxis;
16.
17.
var border =
new
Border();
18.
border.CornerRadius =
new
CornerRadius(4);
19.
border.Background = Brushes.Gray;
20.
border.Opacity = 0.9;
21.
22.
//var content = new TextBlock();
23.
var content =
new
Label();
24.
content.Content =
"Channel "
+ curChannel.ToString();
25.
border.Child = content;
26.
27.
newKLMLabel.Content = border;
28.
newKLMLabel.HorizontalValue = curChannel;
29.
newKLMLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
30.
newKLMLabel.VerticalValue = _chartVM.ParticleEdsSpectrum[curChannel].Counts;
31.
32.
newKLMLabel.Tag =
"klmlabel"
;
33.
34.
newKLMLabel.Visibility = Visibility.Visible;
35.
36.
radCartesianChart1.Annotations.Add(newKLMLabel);
37.
38.
}