WPF Charting 垂直图表

WPF Charting Vertical Chart

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

你可以只做一个LayoutTransform。参考下面的代码。

 <wpfTool:Chart.LayoutTransform>
            <RotateTransform  Angle="90" />
        </wpfTool:Chart.LayoutTransform>

但不确定是否符合您的要求。

我已经弄明白了:)

因此,如果有人想在此处使用适当的轴制作垂直图表:

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