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

Runtime Error with CustomGridLine

1 Answer 51 Views
Chart
This is a migrated thread and some comments may be shown as answers.
müller
Top achievements
Rank 1
müller asked on 02 Dec 2011, 11:05 AM
Hi,
I get a runtime error if i do somthing like this:
<chart:RadChart x:Name="RadChart1"
           <chart:RadChart.DefaultView
               <charting:ChartDefaultView ChartLegendPosition="Top"
                   <charting:ChartDefaultView.ChartLegend
                       <charting:ChartLegend x:Name="PrimaryLegend" Header="Click on country to hide/show:" LegendItemMarkerShape="Square"  Foreground="Black" HeaderFontWeight="Normal" FontFamily="Segoe UI" /> 
                   </charting:ChartDefaultView.ChartLegend
                   <charting:ChartDefaultView.ChartArea
                       <charting:ChartArea Padding="5,10,20,5" LabelFormatBehavior="None" LegendName="PrimaryLegend"
                           <charting:ChartArea.Annotations
                               <charting:CustomGridLine YIntercept="3"
                                                           Visibility="Visible"
                                                           Stroke="Red"
                                                           StrokeThickness="3"/> 
   
                           </charting:ChartArea.Annotations
   
                               <charting:ChartArea.AxisY
                               <charting:AxisY ExtendDirection="None"  /> 
                           </charting:ChartArea.AxisY
                           <charting:ChartArea.DataSeries
                               <charting:DataSeries LegendLabel="EU-27"
                                   <charting:DataSeries.Definition
                                       <charting:LineSeriesDefinition ItemLabelFormat="0.#"
                                           <charting:LineSeriesDefinition.LabelSettings
                                               <charting:LabelSettings ShowConnectors="True" /> 
                                           </charting:LineSeriesDefinition.LabelSettings
                                       </charting:LineSeriesDefinition
                                   </charting:DataSeries.Definition
                                   <charting:DataPoint YValue="0" XValue="1998" /> 
                                   <charting:DataPoint YValue="0" XValue="1999" /> 
                               </charting:DataSeries
                           </charting:ChartArea.DataSeries
                       </charting:ChartArea
                   </charting:ChartDefaultView.ChartArea
               </charting:ChartDefaultView
           </chart:RadChart.DefaultView
       </chart:RadChart>

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 Dec 2011, 09:10 AM
Hello Müller,

The error is caused because you only have '0' values, but the Y interception line is drawn at a higher Y axis value. In such a scenario the best approach would be to set the YAxis AutoRange property to false and define a manual range. You can do this initially or on ItemDataBound event when having only 0 values.

Best wishes,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
müller
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or