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.曲线

相关推荐
安木夕2 小时前
C#-Visual Studio宇宙第一IDE使用实践
前端·c#·.net
gregmankiw5 小时前
C#调用Rust动态链接库DLL的案例
开发语言·rust·c#
阿蒙Amon5 小时前
06. C#入门系列【自定义类型】:从青铜到王者的进阶之路
开发语言·c#
钢铁男儿9 小时前
C# 表达式和运算符(表达式和字面量)
开发语言·c#
林鸿群9 小时前
C#子线程更新主线程UI及委托回调使用示例
开发语言·c#
o0向阳而生0o10 小时前
63、.NET 异常处理
c#·.net·异常处理
SteveDraw12 小时前
C++动态链接库封装,供C#/C++ 等编程语言使用——C++动态链接库概述(总)
开发语言·c++·c#·封装·动态链接库
大霸王龙13 小时前
系统模块与功能设计框架
人工智能·wpf
Kookoos13 小时前
性能剖析:在 ABP 框架中集成 MiniProfiler 实现性能可视化诊断
后端·c#·.net·abp vnext·miniprofiler
阿翰15 小时前
自动 GitHub Readme 20 种语言翻译平台 - OpenAiTx 开源免费
c#·.net