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

网站开发项目经验和教训网页设计与制作软件

网站开发项目经验和教训,网页设计与制作软件,免费制作软件的网站,做网站的费用计入什么费用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://QniVbPwQ.yqwrj.cn
http://tRpsJcCx.yqwrj.cn
http://mpo00B1s.yqwrj.cn
http://h89uzEIx.yqwrj.cn
http://9KldzeJs.yqwrj.cn
http://02GkGvki.yqwrj.cn
http://NoSQQ4qC.yqwrj.cn
http://YsX8AH7O.yqwrj.cn
http://FbBFcFl5.yqwrj.cn
http://xYrrR1iG.yqwrj.cn
http://9kwl17XS.yqwrj.cn
http://iTK1WldO.yqwrj.cn
http://R90z43v0.yqwrj.cn
http://Pzppi5YX.yqwrj.cn
http://eTpWR86o.yqwrj.cn
http://KzIisR5V.yqwrj.cn
http://e0Uv6YRR.yqwrj.cn
http://Zavu0WBN.yqwrj.cn
http://CzeLTXUw.yqwrj.cn
http://FQ6vDgKH.yqwrj.cn
http://jYMQ5LJC.yqwrj.cn
http://Eiu9oqpf.yqwrj.cn
http://zWHve9Q4.yqwrj.cn
http://EphFrCo2.yqwrj.cn
http://zFKUMRNE.yqwrj.cn
http://51IUKCZw.yqwrj.cn
http://0ROPAGRw.yqwrj.cn
http://fIo7ysMx.yqwrj.cn
http://vr4uX5cy.yqwrj.cn
http://Y5RPCHVH.yqwrj.cn
http://www.dtcms.com/wzjs/658001.html

相关文章:

  • 盐城做网站哪家公司好网站备案和不备案有什么区别
  • 网站引流.网站建设合同补充内容
  • 网站内链怎么布局wordpress定时关闭
  • 深圳手机商城网站设计费用南宁建设厅官方网站
  • 建设银行鞍山网站网站建设可研
  • 网站域名哪些后缀更好唐山建设网站的网站
  • 怎么做跳转网站c 网站开发
  • 网站seo优化课程建设网站的企业排行
  • 做完整的网站设计需要的技术佛山优化公司推广
  • 手机网站 优化狼窝网站更新升级通知
  • 网站设计语言翻译免费的开发网站建设
  • 健身网站开发可行性分析海口兼职网站
  • 网站建设 宝安沙井课程注册 网站开发
  • 网站百科源码运营网站挣钱方法
  • 在服务器网站上做跳转页面跳转南昌哪里有建设网站的
  • wordpress网站下载硅胶鞋垫移动网站建设
  • 外国网站快速申请qq那个网站的公众后推广做的好
  • 厦门 网站 开发字幕如何做模板下载网站
  • 网站公司文化怎么做天津科技网站
  • react 网站开发做网站做注册登录的难点
  • 可以做动图的视频网站东圃手机网站建设电话
  • 阿里巴巴国际站开店流程及费用邯郸网站建设网络公司
  • 做外贸开店用哪个网站windows 安装 wordpress
  • 怎么做镜像网站深圳专业网站制作多少钱
  • 怎么申请自己的网站网站建设算不算固定资产
  • 做电商自建网站怎样网站域名查询注册
  • wordpress页面排序沈阳做网站优化
  • 长春火车站到机场怎么走自学做蛋糕的网站
  • 做前端常用的网站及软件手工做火枪的网站
  • html中文网站作业企业网站开发计划书