Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Chart > Text in Legend being cut off.

Answered Text in Legend being cut off.

Feed from this thread
  • GPJ avatar

    Posted on Apr 29, 2009 (permalink)

    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);


    Reply

  • Answer Giuseppe Giuseppe admin's avatar

    Posted on Apr 30, 2009 (permalink)

    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.

    Reply

  • Q1 Webinar Week

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > Chart > Text in Legend being cut off.
Related resources for "Text in Legend being cut off."

WPF Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]