1
votes

How do you rotate the text in the axis from horizontal to vertical?

I cant do it through xaml because I am a creating multiple series on the fly and I do not know up front how many I will have until after the control populates.

enter image description here

I need to display the dates vertical or at a slant and not horz.

Thank you again.

3
Anyone have any clues on how to do this?nitefrog
Posted a link with step-by-step that works for both WPF and Silverlight.Eric J.

3 Answers

3
votes

Not sure if you have found the answer for this, but on the off-chance that you haven't you can try the following:

This is in XAML, but should work no matter how many series' you create as it is styling the axis.

        <chart:Chart.Axes>
            <chart:DateTimeAxis Orientation="X" ShowGridLines="True">
                <chart:DateTimeAxis.AxisLabelStyle>
                    <Style TargetType="{x:Type chart:AxisLabel}">
                        <Setter Property="StringFormat" Value="{}{0:d-MMM}" />
                        <Setter Property="RenderTransformOrigin" Value="1,0.5" />
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <RotateTransform Angle="-45" />
                            </Setter.Value>
                        </Setter>
                    </Style>
                </chart:DateTimeAxis.AxisLabelStyle>
            </chart:DateTimeAxis>

            <chart:LinearAxis ShowGridLines="True" />
        </chart:Chart.Axes>
2
votes

Maybe, that will help:
http://community.devexpress.com/blogs/bryan/archive/2011/01/19/silverlight-and-wpf-charts-changing-the-axis-label-angles.aspx
I know, it's in xaml, but i don't think there is another way, wpf charting is by far not so comfortable like windows forms charting (where you can easily rotate the labels via property).
For your needs you might to write the style into a resource and reference it in your code-behind.