WPF Toolkit 图表中具有相同 Y 轴的两个 LineSeries

发布于 2024-09-17 18:02:59 字数 1942 浏览 5 评论 0原文

我想对 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 的东西,但 2010 年 2 月版本的工具包中安装的版本 3.5.40128.1 并不存在。它是否移动到另一个 clr 命名空间?

I want to do the following with the WPF toolkit charts:

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>

Is there a way to define more than one series with the same Y axis?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

左耳近心 2024-09-24 18:02:59

我遇到了同样的问题并找到了以下方法。您可以将两个系列添加到同一个图表中,并通过将宽度设置为 0 来隐藏第二个系列的轴标签;

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

希望这有帮助

I faced the same issue and found the following way around. You can add the two series to the same chart and hide the second series Axis label by setting the Width to 0;

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

Hope this helps

A君 2024-09-24 18:02:59

我有一个包含 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>

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文