Pre loader

How do you rotate x-axis labels in code?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

Answered
1
1

From reading the material on the site I know how to do what I want to do in xaml:

    <Style x:Key="AxisLabelStyle" TargetType="s:DefaultTickLabel">
    <Setter Property="RenderTransform">
        <Setter.Value>
            <RotateTransform Angle="30"/>
        </Setter.Value>
    </Setter>
    <Setter Property="HorizontalAnchorPoint" Value="Left"/>
</Style>

Now however my chart will be using two diffrent x-axis, one numeric and one with date and time. Both axis are defined in code:

            _xAxisNum = new NumericAxis
        {
            ...
        };

        _xAxisDat = new DateTimeAxis
        {
            ...
        };

        InitializeComponent();
        sciChartSurface.XAxis = _xAxisDat;

What code must I add to my x-axes to get the same result as the xaml above accomplishes? Or can I achieve what I want with a LabelProvider?

  • You must to post comments
Best Answer
1
0

Hi Tomas,

While we recommend you create your styles in XAML and follow the MVVM pattern where possible, you can still do this in code-behind.

Please take a look at this stackoverflow post on How to create a style in Code Behind.

Also this post Implicit styles in Application.Resources shows an alternative way to apply styles globally to all classes of a specific type.

Finally, I would recommend that you use LayoutTransform, not RenderTransform, as this will affect the layout of the axis labels and prevent them from being sized incorrectly.

Best regards,
Andrew

  • You must to post comments
1
0

Thank you! That did the trick.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies