c# wpf LiveCharts 简单试验2

1.概要

1.1 说明

1.2 要点

1.2.1 添加命名控件

复制代码
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"

1.2.2 图片控件

复制代码
<lvc:CartesianChart Name="chart"  LegendLocation="Right"/>

1.3 代码文件引用

复制代码
using LiveCharts.Wpf;
using LiveCharts.Wpf.Charts.Base;

1.4 数据绑定函数

复制代码
private void initView()
{
    SeriesCollection series = new SeriesCollection()
    {
        new LineSeries
        {
            Values = new ChartValues<double> {254,568,563,482,263,104 },
            Fill=new SolidColorBrush(Colors.IndianRed),
        },

    };
    chart.Series = series;
}

2.代码

复制代码
<Window x:Class="WpfApp3.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
        xmlns:local="clr-namespace:WpfApp3"
        mc:Ignorable="d"
        Title="Window1" Height="450" Width="800">
    <Grid>
        <lvc:CartesianChart Name="chart"  LegendLocation="Right"/>
    </Grid>
</Window>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Wpf;
using LiveCharts.Wpf.Charts.Base;

namespace WpfApp3
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            initView();
        }
        private void initView()
        {
            SeriesCollection series = new SeriesCollection()
            {
                new LineSeries
                {
                    Values = new ChartValues<double> {254,568,563,482,263,104 },
                    Fill=new SolidColorBrush(Colors.IndianRed),
                },

            };
            chart.Series = series;
        }
    }
}

3.运行结果

相关推荐
豫狮恒39 分钟前
OpenHarmony Flutter 分布式多模态交互:融合音视频、手势与环境感知的跨端体验革新
flutter·wpf·openharmony
豫狮恒3 小时前
OpenHarmony Flutter 分布式数据共享实战:从基础存储到跨设备协同
flutter·wpf·openharmony
500845 小时前
鸿蒙 Flutter 隐私合规:用户授权中心与数据审计日志
flutter·华为·开源·wpf·音视频
豫狮恒7 小时前
OpenHarmony Flutter 分布式软总线实战:跨设备通信的核心技术与应用
flutter·wpf·harmonyos
Hello.Reader7 小时前
Flink SQL 的 LIMIT 子句语义、坑点与实战技巧
sql·flink·wpf
豫狮恒7 小时前
OpenHarmony Flutter 分布式安全防护:跨设备身份认证与数据加密传输方案
flutter·wpf·openharmony
Wnq100727 小时前
鸿蒙 OS 与 CORBA+DDS+QOS+SOA 在工业控制领域的核心技术对比研究
物联网·性能优化·wpf·代理模式·信号处理·harmonyos·嵌入式实时数据库
豫狮恒7 小时前
OpenHarmony Flutter 分布式设备发现与组网:跨设备无感连接与动态组网方案
分布式·flutter·wpf·openharmony
豫狮恒7 小时前
OpenHarmony Flutter 分布式边缘智能:跨设备算力协同与端侧 AI 推理优化方案
wpf
豫狮恒8 小时前
OpenHarmony Flutter 分布式安全防护:跨设备身份认证与数据加密方案
分布式·安全·flutter·wpf·openharmony