2010-09-05 81 views
2

我想要做的WPF工具圖表如下:兩個供LineSeries用相同的Y軸在WPF工具包圖表

我應該使用相同的Y軸的兩個線系列(即我希望他們既要在同一尺度上)。我可以給他們每一個相同的軸定義,所以他們會重疊(然後讓他們中的一個崩潰的可見性),但這不是我最好的選擇。

這是解決我說的是:

<charts:LineSeries Name="ExternalMeasureSeries" 
       IndependentValueBinding="{Binding Time}" 
       DependentValueBinding="{Binding ExternalMeasure}"> 
    <charts:LineSeries.DataPointStyle> 
     <Style TargetType="charts:LineDataPoint"> 
      <Setter Property="Background" Value="Red"/> 
      <Setter Property="Opacity" Value="0" /> 
     </Style> 
    </charts:LineSeries.DataPointStyle> 
    <!-- Vertical axis for external measure curve --> 
    <charts:LineSeries.DependentRangeAxis> 
     <charts:LinearAxis 
      Orientation="Y" 
      Title="Measurement" 
      Minimum="0" 
      Maximum="30"/> 
    </charts:LineSeries.DependentRangeAxis> 
</charts:LineSeries> 
<charts:LineSeries Name="InternalMeasureSeries" 
        IndependentValueBinding="{Binding Time}" 
        DependentValueBinding="{Binding InternalMeasure}"> 
    <charts:LineSeries.DataPointStyle> 
     <Style TargetType="charts:LineDataPoint"> 
      <Setter Property="Background" Value="Orange"/> 
      <Setter Property="Opacity" Value="0" /> 
     </Style> 
    </charts:LineSeries.DataPointStyle> 
    <!-- Vertical axis for internal measure curve --> 
    <charts:LineSeries.DependentRangeAxis> 
     <charts:LinearAxis 
      Orientation="Y" 
      Minimum="0" 
      Maximum="30" 
      Visibility="Collapsed"/> 
    </charts:LineSeries.DependentRangeAxis> 
</charts:LineSeries> 

有沒有辦法用相同的Y軸定義多個系列?

我發現工具包版本3.5.0.0有一些叫做StackedLineSeries的東西,但是那個版本是3.5.40128.1,它是在2010年2月版的工具包中安裝的,它不在那裏。它移動到另一個clr名稱空間了嗎?

回答

2

我面臨同樣的問題,並發現以下方法。您可以將這兩個系列添加到同一個圖表,並通過將Width設置爲0來隱藏第二個Axis標籤系列;

<charts:LinearAxis 
Orientation="Y" 
Title="Measurement" 
Minimum="0" 
Maximum="30" 
**Width = "0"** 
/> 

希望這有助於

2

我有3個委系列的圖表。前兩個系列代表相對溼度,第三個代表露點。
我想繪製在同一個Y軸上的第一個2系列。我在資源部分創建了我的座標軸。在我的例子中,這是在TabItem

<TabItem Header="rH"> 
<TabItem.Resources> 
    <chartingToolkit:LinearAxis Orientation="Y" HorizontalAlignment="Left" Title="rH /%" x:Key="RHYAxis" /> 
    <chartingToolkit:LinearAxis Orientation="Y" HorizontalAlignment="Right" Title="Dew point /°C" x:Key="DewPointYAxis" /> 
</TabItem.Resources> 
<chartingToolkit:Chart HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Title="Relative Humidity" IsEnabled="True"> 
    <chartingToolkit:Chart.Series> 
     <chartingToolkit:LineSeries DependentRangeAxis="{StaticResource RHYAxis}" IsSelectionEnabled="False" ItemsSource="{Binding Path=RHCollection}" IndependentValuePath="TimeStamp" DependentValuePath="rH" Title="Measured rH" /> 
     <chartingToolkit:LineSeries DependentRangeAxis="{StaticResource RHYAxis}" IsSelectionEnabled="False" ItemsSource="{Binding Path=CorrectedRHCollection}" IndependentValuePath="TimeStamp" DependentValuePath="CorrectedRH" Title="Corrected rH" /> 
     <chartingToolkit:LineSeries DependentRangeAxis="{StaticResource DewPointYAxis}" IsSelectionEnabled="False" ItemsSource="{Binding Path=DewPointCollection}" IndependentValuePath="TimeStamp" DependentValuePath="DewPoint" Title="Dew point" /> 
    </chartingToolkit:Chart.Series> 
</chartingToolkit:Chart>