Skip to main content Skip to footer

How to Rotate Axis Title for FlexChart

You can use the FlexChart Rendered event to provide additional customization such as transforming the Axis Title text.

This is achieved by finding the XAML elements and then you can customize them in code.

flexChart.Rendered += (s, e) =>
{
  var canvas = flexChart.Template.FindName("canvas", flexChart) as Canvas;
  foreach (var el in canvas.Children)
  {
    // find the text
    if(el is TextBlock textBlock && textBlock.Text == flexChart.AxisY.Title)
    {
      // rotate y-axis title
      textBlock.Measure(new System.Windows.Size(double.PositiveInfinity, double.PositiveInfinity));
      var rect = ((C1.Chart.IAxis)flexChart.AxisY).Rect;
      Canvas.SetLeft(textBlock, rect.Center.X);
      Canvas.SetTop(textBlock, rect.Center.Y - 0.5 * textBlock.DesiredSize.Height);
      textBlock.RenderTransform = new RotateTransform(90);
    }
  }
};