This is a migrated thread and some comments may be shown as answers.

Setting Plot Band Annotations from code behind

1 Answer 60 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Terry
Top achievements
Rank 1
Terry asked on 03 Mar 2014, 03:24 AM
Is there a way to set plot band annotations dynamically from C# code behind instead of from XAML?

The examples demonstrate the XAML approach, for instance, 
<telerik:CartesianPlotBandAnnotation Axis="{Binding ElementName=chart3HAxis}" To="3/2/2014" From="3/4/2014" />

but how to accomplish the sample thing using code behind, dynamically. 

1 Answer, 1 is accepted

Sort by
0
Terry
Top achievements
Rank 1
answered on 03 Mar 2014, 04:38 AM
Think I figured it out. For those interested, you can do it as follows:

//horizontal example with dates  X is a DateTime object
 chart3.Annotations.Add(new CartesianPlotBandAnnotation { Label = "plot region", From = chartData[2].X, To = chartData[5].X, Axis = chart3.HorizontalAxis });
 
//vertically Y is a double or just a numeric range like From=3 To=7
chart3.Annotations.Add(new CartesianPlotBandAnnotation { Label = "plot band annotations", From = 0, To = chartData[3].Y, Axis = chart3.VerticalAxis });

Tags
ChartView
Asked by
Terry
Top achievements
Rank 1
Answers by
Terry
Top achievements
Rank 1
Share this question
or