WPF学习(4)--SCICHART学习

一、项目创建过程

1.下载SCICHART插件

2.选中第一个,确保引用中有我们要用的

二、示例代码

1.前端代码

XML 复制代码
<Window x:Class="SciChart.Examples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="http://schemas.abtsoftware.co.uk/scichart">

    <Grid>
        <s:SciChartSurface x:Name="sciChart">
            <s:SciChartSurface.RenderableSeries>
                <s:FastLineRenderableSeries x:Name="lineSeries">
                    <s:FastLineRenderableSeries.DataSeries>
                        <!-- 使用正确的数据系列类型 -->
                        <s:XyDataSeries x:Name="dataSeries"/>
                    </s:FastLineRenderableSeries.DataSeries>
                </s:FastLineRenderableSeries>
            </s:SciChartSurface.RenderableSeries>
        </s:SciChartSurface>
    </Grid>
</Window>

2.后端代码

cs 复制代码
using System;
using System.Windows;
using SciChart.Charting.Model.DataSeries;

namespace SciChart.Examples
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindow_Loaded;
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // 示例数据系列
            var rand = new Random();
            var dataSeries = new XyDataSeries<DateTime, double>();

            // 生成随机数据
            for (int i = 0; i < 100; i++)
            {
                dataSeries.Append(DateTime.Now.AddDays(i), rand.NextDouble() * 100);
            }

            // 将数据系列赋给渲染系列
            lineSeries.DataSeries = dataSeries;

            // 可选:自动调整视图范围
            sciChart.ZoomExtents();
        }
    }
}

3.曲线

相关推荐
hez20103 天前
在 .NET 上构建超大托管数组
c#·.net·.net core·gc·clr
雨落倾城夏未凉8 天前
第四章c#方法-参数数组和可选参数(16)
后端·c#
唐青枫9 天前
线程不是越多越快:C#.NET Thread 生命周期、同步与后台工作线程实战
c#·.net
唐青枫10 天前
别只会反射:C#.NET Emit 动态生成代码实战详解
c#·.net
咕白m62510 天前
.NET 环境下 Word 超链接批量提取方案
c#·.net
用户917215619021110 天前
C# 通信协议增量解析:用状态机处理半包和粘包
c#
小码编匠11 天前
C# 工控上位机必备:数据转换工具类与十个核心模块
后端·c#·.net
唐青枫13 天前
别再乱用 StartNew:C#.NET TaskFactory 任务调度实战详解
c#·.net
Artech13 天前
[MAF预定义的AIContextProvider-03]ChatHistoryMemoryProvider——赋予Agent从经验中学习的能力
ai·c#·agent·memory·maf
Scout-leaf15 天前
C#摸鱼实录——IoC与DI案例详解
c#