wpf工具包图表旋转轴

时间:2011-02-02 02:27:11

标签: c# charts wpftoolkit

如何将轴上的文字从水平旋转到垂直?

我不能通过xaml这样做,因为我是在动态创建多个系列,我不知道在控件填充之前我将拥有多少。

enter image description here

我需要垂直或倾斜显示日期而不是horz。

再次感谢你。

3 个答案:

答案 0 :(得分:3)

不确定您是否找到了答案,但如果您没有找到答案,则可以尝试以下方法:

这是在XAML中,但无论你创建了多少个系列,都应该有效。

        <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>

答案 1 :(得分:3)

答案 2 :(得分:2)

也许,这会有所帮助:
http://community.devexpress.com/blogs/bryan/archive/2011/01/19/silverlight-and-wpf-charts-changing-the-axis-label-angles.aspx
我知道,这是在xaml,但我不认为还有另一种方式,wpf图表到目前为止还不像windows窗体图表那样舒服(你可以通过属性轻松旋转标签)。
根据您的需要,您可以将样式写入资源并在代码隐藏中引用它。

相关问题