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

相关推荐
bestcxx2 分钟前
c# UTC 时间赋值注意事项
c#·utc
酷炫码神5 分钟前
C#运算符
开发语言·c#
CoderIsArt42 分钟前
WPF的UI元素类型详解
ui·wpf
zybsjn1 小时前
后端系统做国际化改造,生成多语言包
java·python·c#
敲代码的 蜡笔小新2 小时前
【行为型之迭代器模式】游戏开发实战——Unity高效集合遍历与场景管理的架构精髓
unity·设计模式·c#·迭代器模式
yc_12242 小时前
SqlHelper 实现类,支持多数据库,提供异步操作、自动重试、事务、存储过程、分页、缓存等功能。
数据库·c#
zxfgdjfjfjflfllf3 小时前
Mapreduce初使用
大数据·wpf·mapreduce
Kookoos3 小时前
Redis + ABP vNext 构建分布式高可用缓存架构
redis·分布式·缓存·架构·c#·.net
Zhen (Evan) Wang5 小时前
ABP-Book Store Application中文讲解 - Part 2: The Book List Page
c#
小乖兽技术6 小时前
在 .NET 8 开发的WinForms 程序中展示程序版本号的几种方式
开发语言·c#·.net