WPF实现曲线数据展示【案例:震动数据分析】

wpf实现曲线数据展示,函数曲线展示,实例:震动数据分析为例。

如上图所示,如果你想实现上图中的效果,请详细参考我的内容,创作不易,给个赞吧。

一共有两种方式来实现,一种是使用第三方的框架来实现,另外一种是自己通过原创代码来一步步实现,本文主要介绍这两种曲线的实现方式。 

1.首先我创建一个wpf的解决方案项目。

2.在NuGet中添加 DynamicDataDisplay 项目支持

为了展示我们的UI界面,我们还添加了一个第三方的样式框架 Panuon.UI.Silver

3.我们在MainWindow.xaml文件中添加如下代码

<d3:ChartPlotter x:Name="plotter">
            <d3:Header x:Name="HeaderTitle" Visibility="Visible" Content="这是曲线的标题" FontSize="14" HorizontalAlignment="Center" />
            <d3:VerticalAxisTitle Content="Value" FontSize="14" Visibility="Collapsed"/>
            <d3:HorizontalAxisTitle Content="时间" FontSize="14" Visibility="Collapsed"/>
        </d3:ChartPlotter>

4.接下来我们就开始实现后台代码部分

  • MainWindow.xaml
    <Window x:Class="WpfApp11.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:pu="clr-namespace:Panuon.UI.Silver;assembly=Panuon.UI.Silver"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:WpfApp11"
            xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
            mc:Ignorable="d"
            Title="MainWindow" Height="450" Width="800">
        <Grid>
    
            <StackPanel Panel.ZIndex="1" Margin="50,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Vertical">
                <CheckBox x:Name="XCheckBox" IsChecked="True"
       pu:CheckBoxHelper.CheckBoxStyle="Standard" 
       pu:CheckBoxHelper.BoxHeight="20" 
       pu:CheckBoxHelper.BoxWidth="20" 
       pu:CheckBoxHelper.CornerRadius="15"
       pu:CheckBoxHelper.CheckedBackground="{Binding ColorX}">
                    <CheckBox.Content>
                        <DockPanel>
                            <TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="X:" Foreground="{Binding ColorX}"/>
                            <TextBlock x:Name="txtFhr1" Text="{Binding ValueX}" FontSize="32" FontWeight="Bold" Foreground="{Binding ColorX}"/>
                        </DockPanel>
                    </CheckBox.Content>
                </CheckBox>
                <CheckBox x:Name="YCheckBox" IsChecked="True" 
                  pu:CheckBoxHelper.CheckedBackground="{Binding ColorY}" pu:CheckBoxHelper.CheckBoxStyle="Standard" pu:CheckBoxHelper.BoxHeight="20" pu:CheckBoxHelper.BoxWidth="20" pu:CheckBoxHelper.CornerRadius="15">
                    <CheckBox.Content>
                        <DockPanel>
                            <TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="Bold" Text="Y:" Foreground="{Binding ColorY}"/>
                            <TextBlock x:Name="txtFhr2" Text="{Binding ValueY}" FontSize="32" FontWeight="Bold" Foreground="{Binding ColorY}" />
                        </DockPanel>
                    </CheckBox.Content>
                </CheckBox>
                <CheckBox x:Name="ZCheckBox" IsChecked="True" 
                  pu:CheckBoxHelper.CheckedBackground="{Binding ColorZ}" pu:CheckBoxHelper.CheckBoxStyle="Sta
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值