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

Rounded Corners and negative values

1 Answer 168 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
XXXX
Top achievements
Rank 1
XXXX asked on 26 Jan 2010, 12:42 PM

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.

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 28 Jan 2010, 08:24 AM
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.
Tags
Chart (Obsolete)
Asked by
XXXX
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or