Runtime Error with CustomGridLine

2 posts, 0 answers
  1. müller
    müller avatar
    3 posts
    Member since:
    Aug 2010

    Posted 02 Dec 2011 Link to this post

    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>
  2. Nikolay
    Admin
    Nikolay avatar
    397 posts

    Posted 07 Dec 2011 Link to this post

    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 >>
Back to Top