DataVisualization.Charting.Chart无法在列系列上叠加lineseries

时间:2013-12-17 19:39:53

标签: wpf charts overlay wpftoolkit

我正在使用WPFToolkit v 3.5.4在列系列上叠加两个线系列,但是系列的“推”在列系列的左侧,如图的顶部图形所示。所有系列都是List< KeyValuePair< double,int>>我检查了键/值对是我想要显示的。

第二张图成功覆盖了三个LineSeries(使用不同的数据),但看起来很差。

有没有办法在同一图表上混合图表系列类型(ColumnSeries,LineSeries)?

由于

这是图像中两个图形的Xaml:

<chartingToolkit:Chart  Name="lineChart1" Title="Series1" VerticalAlignment="Top" Margin="449,39,43,0" Height="262">

    <chartingToolkit:ColumnSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [0]}" 
                                IsSelectionEnabled="True" />
    <chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [1]}" 
                                IsSelectionEnabled="True" />
    <chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [2]}" 
                                IsSelectionEnabled="True" />
    <!-- Remove the legend -->
    <chartingToolkit:Chart.LegendStyle>
        <Style TargetType="Control">
            <Setter Property="Width" Value="0"/>
            <Setter Property="Height" Value="0"/>
        </Style>
    </chartingToolkit:Chart.LegendStyle>
</chartingToolkit:Chart>

<chartingToolkit:Chart  Name="lineChart2" Title="Series2" VerticalAlignment="Top" Margin="33,330,440,0" Height="262">
    <chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [0]}" 
                                IsSelectionEnabled="True" />
    <chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [1]}" 
                                IsSelectionEnabled="True" />
    <chartingToolkit:LineSeries DependentValuePath="Value" IndependentValuePath="Key" ItemsSource="{Binding [2]}" 
                                IsSelectionEnabled="True" />
    <chartingToolkit:Chart.LegendStyle>
        <Style TargetType="Control">
            <Setter Property="Width" Value="0"/>
            <Setter Property="Height" Value="0"/>
        </Style>
    </chartingToolkit:Chart.LegendStyle>
</chartingToolkit:Chart>

Two Graphs

1 个答案:

答案 0 :(得分:0)

您需要为第一个图表设置LinearAxis,因为您先放置ColumnSeries,然后使用CategoryAxis而不是正确的。{/ p>

以下是第一张图表的代码:

<chartingToolkit:Chart  Name="lineChart1" Title="Series1" VerticalAlignment="Top" Margin="449,39,43,0" Height="262">
    <chartingToolkit:Chart.Axes>
        <chartingToolkit:LinearAxis Orientation="X" />
    </chartingToolkit:Chart.Axes>
...

第二个图表的代码是正确的,但由于您用于绑定的数据,图表看起来很糟糕。

发布C#代码,您可以在其中设置DataContext属性并发布您在那里使用的值。