Articles in this section
Category / Section

How to display the labels inside segments in WPF Chart (SfChart)?

1 min read

Labels can be placed inside the column segments using ChartAdornment. WPF Chart (SfChart) series adornments are used to display values related to a ChartSegment. The ChartAdornmentsInfo class is used to display chart series adornments. We can customize the chart series adornments using the SegmentLabelContent, ConnectorLineStyle, SymbolTemplate, and LabelTemplate properties. The positioning of adornments in the series also depends on the AdornmentsPosition property-value. The LabelTemplate property can be used as shown in the following code example to display the labels inside the chart segment.

XAML

<Syncfusion:ColumnSeries.AdornmentsInfo>
    <Syncfusion:ChartAdornmentInfo SegmentLabelContent="LabelContentPath" ShowLabel="True" AdornmentsPosition="TopAndBottom" >
         <Syncfusion:ChartAdornmentInfo.LabelTemplate>
              <DataTemplate>
                   <!--LabelTemplate for Segments.A TextBlock inside each Segments--> 
                   <TextBlock Foreground="White" FontSize="25" FontWeight="Bold" Text="{Binding Item.CompanyName}" RenderTransformOrigin="0.5,0.5">
                        <TextBlock.RenderTransform>
                             <RotateTransform Angle="-90"></RotateTransform>
                        </TextBlock.RenderTransform>
                   </TextBlock>
              </DataTemplate>
         </Syncfusion:ChartAdornmentInfo.LabelTemplate>
    </Syncfusion:ChartAdornmentInfo>
</Syncfusion:ColumnSeries.AdornmentsInfo>

 

WPF Chart displays Label Segment

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied