I want to change ItemLabe font size of Pie Chart!!!!

9 posts, 0 answers
  1. Minseok Bang
    Minseok Bang avatar
    19 posts
    Member since:
    Oct 2009

    Posted 17 Nov 2009 Link to this post

    I use SeriesItemLabelStyle for changing Bar ItemLabel fontsize.

    It work but that is not working for Pie Chart!

    Style apply to Pie Chart

    All of ItemLabel of PieChart is overlaped!

    Definition.LabelOffset is not Work, like any other Properies.

    Let me know Hint.

    Thanks.
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 20 Nov 2009 Link to this post

    Hi Minseok,

    Here is a code snippet setting the font size using SeriesItemLabelStyle:
    <t:RadChart x:Name="radChart1">
        <t:RadChart.Resources>
            <Style x:Key="ItemLabelStyleTest" TargetType="t:SeriesItemLabel">
                <Setter Property="FontSize" Value="40" />
            </Style>
        </t:RadChart.Resources>
    </t:RadChart>

    And the code-behind:
    public partial class Page1 : UserControl
    {
        public Page1()
        {
            InitializeComponent();
            PieSeriesDefinition pieDef = new PieSeriesDefinition() {
                     SeriesItemLabelStyle = this.radChart1.Resources["ItemLabelStyleTest"] as Style
            };
     
            // ...
        }
    }

    Best,
    Evtim
    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.
  3. Minseok Bang
    Minseok Bang avatar
    19 posts
    Member since:
    Oct 2009

    Posted 20 Nov 2009 Link to this post

    Thank you so much!!

  4. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 01 Feb 2010 Link to this post

    How do you do this in code-behind only? I add charts dynamically in C# and don't have an initial "radChart1" in XAML which resources I can use... I just need to change the font size for point labels in my Line CHart.
  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 04 Feb 2010 Link to this post

    Hello Anne,

    You can define the style in any resource dictionary you like, not just the RadChart one. I suggest using the LayoutRoot resource dictionary.

    Another way is to build the whole style in the code-behind:
    Style style = new Style(typeof(SeriesItemLabel));
    style.Setters.Add(new Setter(Control.FontSizeProperty, 40d));

    Regards,
    Evtim
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  6. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 04 Feb 2010 Link to this post

    Thanks,

    This works fine if I execute this code as I add the series to the charts (using seriesMapping.SeriesDefinition.SeriesItemLabelStyle) but it does nothing if I want to let the user set the font size himself.
    I have a callback from a context menu that basically sets font large or small:
                          switch (mnuText)  
                            {  
                                    case "Set font large":  
                                        Style style = new Style(typeof(SeriesItemLabel));  
                                        style.Setters.Add(new Setter(Control.FontSizeProperty, 16d));  
                                        aChart.DefaultView.ChartArea.DataSeries[0].Definition.ShowItemLabels = true;  
                                        aChart.DefaultView.ChartArea.DataSeries[0].Definition.SeriesItemLabelStyle = style;  
                                        menuItem.Header = "Set font small";  
                                        break;  
                                    case "Set font small":  
                                         style = new Style(typeof(SeriesItemLabel));  
                                        style.Setters.Add(new Setter(Control.FontSizeProperty, 8d));  
                                        aChart.DefaultView.ChartArea.DataSeries[0].Definition.ShowItemLabels = true;  
                                        aChart.DefaultView.ChartArea.DataSeries[0].Definition.SeriesItemLabelStyle = style;  
                                        menuItem.Header = "Set font large";  
                                        break;  
                }  
     
    This does not at all change the font size, am I doing anything wrong?
  7. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 09 Feb 2010 Link to this post

    Hello Anne,

    The style set through the definition is retrieved when the series is created, and changing it later does not affect the already created series.

    There is no way to dynamically update the items style.

    Kind regards,
    Joshua
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. Anne Lyon
    Anne Lyon avatar
    90 posts
    Member since:
    Jan 2010

    Posted 09 Feb 2010 Link to this post

    Thanks,
    then at least I know that we cannot offer such a functionality to the users...
    But it might be an idea to put on your "nice-to-have" list that ALL attributes for a chart should be possible to change dynamically? We find very often that a user would like to change the look of a chart (colors, fonts, labels), especially before exporting to presentations, reports etc.
  9. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 10 Feb 2010 Link to this post

    Hi Anne,

    We totally agree with your point. Most issues come from legacy code written to support Silverlight 2. We have to balance between further development of the RadChart and removal of code that deals with SL2 restrictions. Since SL4 is coming, we delayed those modifications to directly target SL4.

    Currently, you can overcome the issue by reloading the data series (or rebinding the chart, should you use that approach).

    Regards,
    Joshua
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top