我有WPF工具包,我需要从顶部开始做垂直图表。 我正在尝试很多东西,但总是我最终得到的错误或图表从左到右。我不知道该怎么做,我找不到任何帮助:(
例如,这会引发错误:
<chart:Chart x:Name="LasChart" Width="764" HorizontalAlignment="Left" VerticalAlignment="Top" Height="896">
<chart:LineSeries Name="LasData" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}">
<chart:LineSeries.DependentRangeAxis>
<chart:LinearAxis Orientation="X" Location="Top"/>
</chart:LineSeries.DependentRangeAxis>
</chart:LineSeries>
</chart:Chart>
答案 0 :(得分:1)
你可以做一个LayoutTransform。请参阅下面的代码。
<wpfTool:Chart.LayoutTransform>
<RotateTransform Angle="90" />
</wpfTool:Chart.LayoutTransform>
但不确定它是否符合您的要求。
答案 1 :(得分:0)
我已经想出来了:))
因此,如果有人想在这里使用适当的轴做垂直图表,那就是:
<chart:Chart x:Name="LasChart" HorizontalAlignment="Left" VerticalAlignment="Top" UseLayoutRounding="False" Height="686">
<chart:Chart.LayoutTransform>
<RotateTransform Angle="90" />
</chart:Chart.LayoutTransform>
<chart:Chart.Axes>
<chart:CategoryAxis Orientation="X"
Location="Bottom"
Foreground="Black">
<chart:CategoryAxis.AxisLabelStyle>
<Style TargetType="chart:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="chart:AxisLabel">
<TextBlock
Text="{TemplateBinding FormattedContent}"
TextAlignment="Center"
RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<RotateTransform Angle="-90" />
</TextBlock.RenderTransform>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</chart:CategoryAxis.AxisLabelStyle>
</chart:CategoryAxis>
<chart:LinearAxis Orientation="Y"
Location="Left"
Foreground="Black">
<chart:LinearAxis.AxisLabelStyle>
<Style TargetType="chart:AxisLabel">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="chart:AxisLabel">
<TextBlock
Text="{TemplateBinding FormattedContent}"
TextAlignment="Center"
RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<RotateTransform Angle="-90" />
</TextBlock.RenderTransform>
</TextBlock>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</chart:LinearAxis.AxisLabelStyle>
</chart:LinearAxis>
</chart:Chart.Axes>
<chart:LineSeries Name="LasData" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}">
</chart:LineSeries>
<chart:Chart.LegendStyle>
<Style TargetType="Control">
<Setter Property="Width" Value="0" />
<Setter Property="Height" Value="0" />
</Style>
</chart:Chart.LegendStyle>
</chart:Chart>