Rounded Corners and negative values

Thread is closed for posting
2 posts, 0 answers
  1. XXXX
    XXXX avatar
    57 posts
    Member since:
    Jun 2008

    Posted 26 Jan 2010 Link to this post

    When applying round to top corners on a Bar chart doesn't give the results I was looking for for negative values.
    On the bars presenting negative values the actual top corners are rounded not the corners that are furtherst away from the axis.

    This markup for a chart displays this:

    <telerik:RadChart ID="RadChart1" runat="server" > 
       <Series> 
          <telerik:ChartSeries Name="Series 1">  
             <Appearance Corners="Round, Round, Rectangle, Rectangle, 3">  
             </Appearance> 
             <Items> 
                <telerik:ChartSeriesItem Name="Item 1" YValue="10">  
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 2" YValue="30">  
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 3" YValue="-10">  
                </telerik:ChartSeriesItem> 
                <telerik:ChartSeriesItem Name="Item 4" YValue="10">  
                </telerik:ChartSeriesItem> 
             </Items> 
          </telerik:ChartSeries> 
       </Series> 
       <ChartTitle> 
          <TextBlock Text="Rounded Negative Corner">  
             <Appearance TextProperties-Color="Black" TextProperties-Font="Arial, 18pt">  
             </Appearance> 
          </TextBlock> 
       </ChartTitle> 
    </telerik:RadChart> 

    A workaround for this is simple for static chart (like the one above) all that is needed is to apply <Appearance Corners="Rectangle, Rectangle, Round, Round, 3" /> to the items with negative values.
    The following code (C#) does this on itemDataBound for charts that are databound.
            protected void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)  
            {  
                    if (e.SeriesItem.YValue < 0)  
                    {  
                        e.SeriesItem.Appearance.Corners.BottomLeft = Telerik.Charting.Styles.CornerType.Round;  
                        e.SeriesItem.Appearance.Corners.BottomRight = Telerik.Charting.Styles.CornerType.Round;  
                        e.SeriesItem.Appearance.Corners.TopLeft = Telerik.Charting.Styles.CornerType.Rectangle;  
                        e.SeriesItem.Appearance.Corners.TopRight = Telerik.Charting.Styles.CornerType.Rectangle;  
                    }  
            } 

    Hope this can be of help to someone.
  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 28 Jan 2010 Link to this post

    Hello Bjössi,

    Thanks for sharing your solution. Your Telerik points have been updated.

    Greetings,
    Ves
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top