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

相关推荐
淡海水7 小时前
01-03-认知篇-C#内存模型深度解析
unity·c#·游戏引擎·.net·gc
lzhdim13 小时前
C#不为人知的10个魔法特性:资深开发者也会震惊的底层奥秘
java·前端·javascript·算法·c#
SamChan9015 小时前
PDF页面旋转与CropBox陷阱:译文回填位置总是错位的根因实测
python·ai·pdf·wpf
前端 贾公子16 小时前
LangChain核心组件 == 提示词(Prompts)
开发语言·c#
码艺-Alimjan18 小时前
Web 网站打包桌面应用的另一种方式,超级简单(C# exe 33Kb)
开发语言·前端·c#
海天鹰19 小时前
C#入门:显示窗口
c#
淡海水19 小时前
16-02-C#常用数据结构源码-附录B-源码索引速查
unity·c#·游戏引擎·il2cpp
海天鹰20 小时前
C#入门:在cmd显示字符
c#
波力海苔夹心脆6751 天前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
小羊没烦恼!2 天前
在Scrum中实施敏捷建模
java·开发语言·windows·算法·c#