Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > Pie Chart Styling
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Pie Chart Styling

Feed from this thread
  • Ros avatar

    Posted on Apr 8, 2011 (permalink)

    I am using radChart 2.9.1.0 and having some problems styling my pie chart legend, specifically when there are a lot of items to be displayed.

    Firstly can I ask what chart.Legend.AutoSize = True does? I am unsure whether this is helping or hindering me.

    I am using the following code, which works fine for things with a small number of items but doesn't work for a larger number (see attached image where the legend is hiding part of the chart and half the legend is not showing):
     

     Dim rc As New RadChart

    rc.Margins.Top = 30
    rc.Margins.Right = 162
    rc.Margins.Bottom = 30
    rc.Width = 600
    rc.Height = 335
    rc.Legend.AutoSize = True
    rc.Legend.HeightRatio = 2
     

    I appreciate that I can make the chart wider and make the right margin larger (although I am not sure how I can accuratly predict what size is best) and I have tried setting HeightRatio to 1 which means all of my legend items show up but I get 2 different length columns and then have to make my chart wider and increase the right margin again.

    I think the best solution to my problems would be to have the legend benether the chart, in one column. But again I have tried setting

    rc.Legend.Position = ChartPosition.Bottom

    rc.Legend.Location = ChartLocation.OutsidePlotArea

     

     

     

    and increasing the height and bottom margin but I haven't been able to get this to display at all well.

     

     

     

     

    Any advice you can provide would be much appreciated. 

    Attached files

  • Ves Ves admin's avatar

    Posted on Apr 13, 2011 (permalink)

    Hi Ros,

    Onto the AutoSize property -- its default value is true, meaning, that RadChart will define the legend size according to the content. You should set it to false if you need to provide your own size settings.

    Unfortunately, this version of RadChart is quite old and it does not include features like the automatic layout calculation and specific legend items order orientation (row or column), available in later versions of the control (ASP.NET AJAX versions). Version 2.9.1. is not as flexible and the means for handling such situations are limited. You have already found the HeightRatio and WidthRatio properties. Alternatively, you can define your own size for the legend. Unfortunately both these require some knowledge about the number of items shown. I have attached a small example, showing both approaches (one is commented out). You can enhance them with some heuristics (e.g. you can add additional pixels to the legend height for every third item available or increment the HeightRatio property in a similar manner).

    Kind regards,
    Ves
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > Pie Chart Styling