当前位置: 首页 > wzjs >正文

做设计英文网站乔拓云网站注册

做设计英文网站,乔拓云网站注册,ppt模板免费模板下载,镇江网站关键字优化WPF LiveCharts.WPF 封装实现 下面是一个完整的 WPF LiveCharts.WPF 封装实现,提供了常用图表的简单使用方式,并支持数据绑定和更新。 一、LiveCharts.WPF 封装类 1. 图表基类 (ChartBase.cs) using LiveCharts; using LiveCharts.Wpf; using System.Collections.Generic;…

WPF LiveCharts.WPF 封装实现

下面是一个完整的 WPF LiveCharts.WPF 封装实现,提供了常用图表的简单使用方式,并支持数据绑定和更新。

一、LiveCharts.WPF 封装类

1. 图表基类 (ChartBase.cs)

 
using LiveCharts;
using LiveCharts.Wpf;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;namespace WpfSupervisor.Charts
{public abstract class ChartBase : UserControl{protected ChartValues<double> _chartValues = new ChartValues<double>();protected SeriesCollection _seriesCollection = new SeriesCollection();protected LiveCharts.Wpf.Axis _xAxis = new LiveCharts.Wpf.Axis();protected LiveCharts.Wpf.Axis _yAxis = new LiveCharts.Wpf.Axis();static ChartBase(){// 设置默认样式DefaultStyles.Initialize();}public ChartBase(){InitializeComponent();SetupChart();}protected abstract void InitializeComponent();protected abstract void SetupChart();public void UpdateData(IEnumerable<double> newData){_chartValues.Clear();foreach (var value in newData){_chartValues.Add(value);}OnPropertyChanged(nameof(ChartValues));}public void AddDataPoint(double value){_chartValues.Add(value);OnPropertyChanged(nameof(ChartValues));}public void ClearData(){_chartValues.Clear();OnPropertyChanged(nameof(ChartValues));}public SeriesCollection SeriesCollection{get => _seriesCollection;set{_seriesCollection = value;OnPropertyChanged(nameof(SeriesCollection));}}public ChartValues<double> ChartValues{get => _chartValues;set{_chartValues = value;OnPropertyChanged(nameof(ChartValues));}}public LiveCharts.Wpf.Axis XAxis{get => _xAxis;set{_xAxis = value;OnPropertyChanged(nameof(XAxis));}}public LiveCharts.Wpf.Axis YAxis{get => _yAxis;set{_yAxis = value;OnPropertyChanged(nameof(YAxis));}}public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;protected void OnPropertyChanged(string propertyName){PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));}}
}

2. 折线图封装 (LineChartControl.xaml & LineChartControl.xaml.cs)

​LineChartControl.xaml​

 
<UserControl x:Class="WpfSupervisor.Charts.LineChartControl"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"xmlns:local="clr-namespace:WpfSupervisor.Charts"x:Name="root"><lvc:CartesianChart Series="{Binding SeriesCollection, ElementName=root}" Axes="{Binding Axes, ElementName=root}"LegendLocation="Right"Hoverable="False"DataTooltip="{x:Null}"><lvc:CartesianChart.ChartLegend><lvc:DefaultLegend BulletSize="10" /></lvc:CartesianChart.ChartLegend><lvc:CartesianChart.Zoom><lvc:ZoomingOptions ZoomMode="X" /></lvc:CartesianChart.Zoom></lvc:CartesianChart>
</UserControl>

​LineChartControl.xaml.cs​

 
using LiveCharts;
using LiveCharts.Wpf;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Media;namespace WpfSupervisor.Charts
{public partial class LineChartControl : ChartBase{public static readonly DependencyProperty TitleProperty =DependencyProperty.Register("Title", typeof(string), typeof(LineChartControl), new PropertyMetadata("折线图", OnTitleChanged));public static readonly DependencyProperty LineColorProperty =DependencyProperty.Register("LineColor", typeof(Brush), typeof(LineChartControl), new PropertyMetadata(new SolidColorBrush(Colors.Blue), OnLineColorChanged));public string Title{get => (string)GetValue(TitleProperty);set => SetValue(TitleProperty, value);}public Brush LineColor{get => (Brush)GetValue(LineColorProperty);set => SetValue(LineColorProperty, value);}public LineChartControl(){InitializeComponent();}protected override void InitializeComponent(){// 已在XAML中定义}protected override void SetupChart(){_seriesCollection = new SeriesCollection{new LineSeries{Title = Title,Values = ChartValues,PointGeometrySize = 5,Stroke = LineColor,Fill = Brushes.Transparent}};_xAxis = new LiveCha
http://www.dtcms.com/wzjs/375253.html

相关文章:

  • 百度站长资源网络营销方式有几种
  • 武汉专业做网站公司seo建站
  • 网页布局设计主要有什么类型整站seo怎么做
  • 大连做网站优化公司百度提交入口的网址
  • 论坛类网站可以做移动端吗专业网站制作
  • 济南品质网站建设哪家好7月新闻大事件30条
  • 正品手表网站seo入门书籍推荐
  • 东营网站建设公司凡科建站小程序
  • 开发网站的成本seo中心
  • 做阿里国际网站多少钱青岛网站制作seo
  • 咸阳公司做网站网页设计与制作模板
  • 设计色彩的门户网站模板seo优化与推广招聘
  • 身份证和手机做验证码注册网站爱站工具查询
  • 哪家做网站关键词首页排名优化公司推荐
  • 网站404页面优化百度明星人气排行榜
  • 春雨直播免费视频上海优化营商环境
  • 网页设计专业就业前景网站网络推广优化
  • 南昌网站建设 南昌做网站公司百度客户端下载
  • 官方网站建设案例百度seo引流怎么做
  • 头条号链接其他网站怎么做免费的网站
  • 网络公司网站建设报价seo外包公司是啥
  • 百度优化网站建设百度seo教程视频
  • 万网域名查询工具汕头seo推广优化
  • 怎么用dw做网站八百客crm登录入口
  • 贵阳网站建设哪家好方舟口碑营销的名词解释
  • 贵州省建设执业资格促进会网站深圳竞价托管
  • 建设企业网站的公司文案写作软件app
  • 建设网站需要哪些硬件百度网盘怎么提取别人资源
  • 在美国建设网站微商推广哪家好
  • 莆田网站设计百度百家号注册