SciChart WPF 2D Charts > Axis APIs > Axis Styling - Templating Axis Labels
Axis Styling - Templating Axis Labels

Templating Axis Labels

Axis labels can be rotated if you style them via the AxisCore.TickLabelStyle property.

Templating Axis Labels
Copy Code
<Grid>
   <Grid.Resources>
      <Style x:Key="RotatedTickLabelStyle" TargetType="s:DefaultTickLabel">
         <Setter Property="Foreground" Value="Orange"></Setter>
         <Setter Property="FontSize" Value="16"/>
         <Setter Property="FontFamily" Value="Segoe UI"/>
         <Setter Property="LayoutTransform">
            <Setter.Value>
               <RotateTransform Angle="90"/>
            </Setter.Value>
         </Setter>
       <!-- Optionally override ControlTemplate for the label -->
       <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="labelProviders:DefaultTickLabel">
               <ContentControl Content="{Binding}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  Foreground="{TemplateBinding Foreground}" IsTabStop="False" />
            </ControlTemplate>
         </Setter.Value>
       </Setter>
      </Style>
   </Grid.Resources>
  
   <!--  Create the chart surface  -->
   <!-- where xmlns:s="http://schemas.abtsoftware.co.uk/scichart" -->
   <s:SciChartSurface>

   <!--  Create XAxis  -->
   <s:SciChartSurface.XAxis>
      <s:NumericAxis AxisTitle="Styled XAxis" TextFormatting="0.000" TickLabelStyle="{StaticResource RotatedTickLabelStyle}"/>
   </s:SciChartSurface.XAxis>

   <!--  Create YAxis  -->
   <s:SciChartSurface.YAxes>
      <s:NumericAxis AxisTitle="Primary YAxis" AxisAlignment="Left"/>
      <s:NumericAxis Id="SecondaryYAxisId" AxisTitle="Secondary YAxis" AxisAlignment="Right" />
   </s:SciChartSurface.YAxes>

   </s:SciChartSurface>
</Grid>

See Also