WPF工具包图表中具有相同Y轴的两个LineSeries [英] Two LineSeries with the same Y Axis in WPF Toolkit charts
问题描述
我想对WPF工具包图表执行以下操作:
I want to do the following with the WPF toolkit charts:
我有两条线系列应该使用相同的y轴(即,我希望它们都成为在相同的规模上)。我可以给它们每个都相同的轴定义,以便它们可以重叠(然后使其中一个具有可见性折叠),但这不是我的最佳选择。
I have two line series that should use the same y axis (i.e I want them both to be on the same scale). I could give each of them the same axis definition so they would overlap (and then have one of them with collapsed visibility), but that is not my best choice.
是我正在谈论的解决方案:
This is the solution I'm talking about:
<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轴的序列?
Is there a way to define more than one series with the same Y axis?
我发现工具包版本3.5.0.0中有一个叫做 StackedLineSeries
的东西,但是版本3.5.40128.1是在2010年2月安装的版本的工具箱,它不存在。
I found that toolkit version 3.5.0.0 has something called StackedLineSeries
but that version 3.5.40128.1 which is what gets installed in the February 2010 version of the toolkit, it isn't there. Did it move to another clr-namespace?
推荐答案
我有一个包含3条线的图表。前两个系列代表相对湿度,第三个系列代表露点。
我想在同一Y轴上绘制前两个系列。我在资源部分中创建了轴。在我的示例中,这在 TabItem
中。
I have a chart with 3 line series. The first 2 series represent the relative humidity and the third one represent the dew point.
I want to draw the first 2 series on the same Y axis. I created my axes in a resource section. In my example, this is in a 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>
这篇关于WPF工具包图表中具有相同Y轴的两个LineSeries的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!