Text in Legend being cut off.

2 posts, 1 answers
  1. GPJ
    GPJ avatar
    31 posts
    Member since:
    Oct 2008

    Posted 29 Apr 2009 Link to this post

    The bottom of the text strings in my pie chart legend is being cut off....  Not sure why since I am just using the basic styles.

    XAML

                <telerik:RadChart x:Name="ProgressChart"
                                  Margin="4,8,4,4"
                                  VerticalAlignment="Stretch"
                                  HorizontalAlignment="Stretch">
                    <telerik:RadChart.Background>
                        <SolidColorBrush Color="Transparent"/>
                    </telerik:RadChart.Background>
                </telerik:RadChart>

    Code Behind

                ProgressChart.Visibility = Visibility.Visible;
                ProgressChart.DefaultView.ChartArea.DataSeries.Clear();

                var areaSeries = new DataSeries {Definition = new PieSeriesDefinition()};

                areaSeries.LegendLabel = "test";
                areaSeries.Definition.ShowItemLabels = true;

                areaSeries.Add(new DataPoint(_dataList.Completed, _dataList.Completed));
                areaSeries.Add(new DataPoint(_dataList.Incomplete, _dataList.Incomplete));

                areaSeries[0].LegendLabel = "Completed";
                areaSeries[1].LegendLabel = "Incomplete";
                ProgressChart.DefaultView.ChartArea.DataSeries.Add(areaSeries);


  2. Answer
    Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 30 Apr 2009 Link to this post

    Hello Greg Peter Joyal,

    Unfortunately we must admit this is a bug within the legend item control template. We have added this issue to our bugtracking system and we will make sure it is fixed for the next official release of the control. As a workaround for the moment we can suggest you to use the following template for the legend item (applied via setting ChartLegend.LegendItemStyle property in code-behind):

    XAML
    <control:RadChart x:Name="ProgressChart"
        <control:RadChart.Resources> 
            <Style TargetType="chart:ChartLegendItem"
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="chart:ChartLegendItem"
                            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top"
                                <Grid.ColumnDefinitions> 
                                    <ColumnDefinition Width="Auto" /> 
                                    <ColumnDefinition /> 
                                </Grid.ColumnDefinitions> 
     
                                <Rectangle x:Name="PART_LegendItemMarker" 
                                Height="15"  
                                Width="30" 
                                StrokeThickness="2" 
                                RadiusX="2" 
                                RadiusY="2" 
                                HorizontalAlignment="Left"  
                                VerticalAlignment="Bottom" 
                                Margin="0,0,0,5" 
                                Style="{TemplateBinding ItemStyle}" /> 
     
                                <TextBlock Grid.Column="1" 
                                Padding="0" 
                                Margin="5,5,5,5" 
                                VerticalAlignment="Center" 
                                Foreground="White" 
                                Text="{TemplateBinding Label}" /> 
                            </Grid> 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
        </control:RadChart.Resources> 
    </control:RadChart> 


    C#
    DataSeries series = new DataSeries(); 
    series.Definition = new PieSeriesDefinition(); 
    series.Add(new DataPoint(40)); 
    series.Add(new DataPoint(21)); 
     
    series[0].LegendLabel = "Completed"
    series[1].LegendLabel = "Incomplete"
     
    ProgressChartProgressChart.DefaultView.ChartLegend.LegendItemStyle = ProgressChart.Resources["CustomLegendItemStyle"] as Style; 
     
    ProgressChart.DefaultView.ChartArea.DataSeries.Add(series); 


    Hope this helps. We have updated your Telerik points for the report as well.


    Kind regards,
    Manuel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top