首页 > 其他分享 >LiveCharts控件基本使用

LiveCharts控件基本使用

时间:2023-11-15 20:56:57浏览次数:43  
标签:基本 控件 Title cartesianChart1 ChartValues Values new using LiveCharts

Angular Ganuge控件

 

 1 using System.Windows;
 2 using System.Windows.Forms;
 3 using System.Windows.Media;
 4 using LiveCharts.Wpf;
 5 using Brushes = System.Windows.Media.Brushes;
 6  
 7 namespace Winforms.Gauge.AngularGauge
 8 {
 9     public partial class AngularGugeForm : Form
10     {
11         public AngularGugeForm()
12         {
13             InitializeComponent();
14  
15             angularGauge1.Value = 160;
16             angularGauge1.FromValue = 50;
17             angularGauge1.ToValue = 250;
18             angularGauge1.TicksForeground = Brushes.White;
19             angularGauge1.Base.Foreground = Brushes.White;
20             angularGauge1.Base.FontWeight = FontWeights.Bold;
21             angularGauge1.Base.FontSize = 16;
22             angularGauge1.SectionsInnerRadius = 0.5;
23  
24             angularGauge1.Sections.Add(new AngularSection
25             {
26                 FromValue = 50, 
27                 ToValue = 200,
28                 Fill = new SolidColorBrush(Color.FromRgb(247,166,37))
29             });
30             angularGauge1.Sections.Add(new AngularSection
31             {
32                 FromValue = 200,
33                 ToValue = 250,
34                 Fill = new SolidColorBrush(Color.FromRgb(254, 57, 57))
35             });
36         }
37     }
38 }

Solid Gauge

 

 1 using System.Windows;
 2 using System.Windows.Forms;
 3 using System.Windows.Media;
 4  
 5 namespace Winforms.Gauge._360
 6 {
 7     public partial class Gauge360Example : Form
 8     {
 9         public Gauge360Example()
10         {
11             InitializeComponent();
12  
13             //360 mode enabled
14             solidGauge1.Uses360Mode = true;
15             solidGauge1.From = 0;
16             solidGauge1.To = 100;
17             solidGauge1.Value = 50;
18  
19             //rotated 90° and has an inverted clockwise fill
20             solidGauge2.Uses360Mode = true;
21             solidGauge2.From = 0;
22             solidGauge2.To = 100;
23             solidGauge2.Value = 50;
24             solidGauge2.Base.GaugeRenderTransform = new TransformGroup
25             {
26                 Children = new TransformCollection
27                 {
28                     new RotateTransform(90),
29                     new ScaleTransform {ScaleX = -1}
30                 }
31             };
32  
33             solidGauge3.Uses360Mode = true;
34             solidGauge3.From = 0;
35             solidGauge3.To = 100;
36             solidGauge3.Value = 20;
37             solidGauge3.HighFontSize = 60;
38             solidGauge3.Base.Foreground = Brushes.White;
39             solidGauge3.InnerRadius = 0;
40             solidGauge3.GaugeBackground = new SolidColorBrush(Color.FromRgb(71,128,181));
41  
42             //the next gauge interpolates from color white, to color black according
43             //to the current value in the gauge
44             solidGauge4.Uses360Mode = true;
45             solidGauge4.From = 0;
46             solidGauge4.To = 100;
47             solidGauge4.Value = 50;
48             solidGauge4.HighFontSize = 60;
49             solidGauge4.Base.Foreground = new SolidColorBrush(Color.FromRgb(66,66,66));
50             solidGauge4.FromColor = Colors.White;
51             solidGauge4.ToColor = Colors.Black;
52             solidGauge4.InnerRadius = 0;
53             solidGauge4.Base.Background = Brushes.Transparent;
54  
55             //standard gauge
56             solidGauge5.From = 0;
57             solidGauge5.To = 100;
58             solidGauge5.Value = 50;
59  
60             //custom fill
61             solidGauge6.From = 0;
62             solidGauge6.To = 100;
63             solidGauge6.Value = 50;
64             solidGauge6.Base.LabelsVisibility = Visibility.Hidden;
65             solidGauge6.Base.GaugeActiveFill = new LinearGradientBrush
66             {
67                 GradientStops = new GradientStopCollection
68                 {
69                     new GradientStop(Colors.Yellow, 0),
70                     new GradientStop(Colors.Orange, .5),
71                     new GradientStop(Colors.Red, 1)
72                 }
73             };
74         }
75     }
76 }

Pie Chart

 

 1 using System;
 2 using System.Windows.Forms;
 3 using LiveCharts;
 4 using LiveCharts.Wpf;
 5  
 6 namespace Winforms.PieChart
 7 {
 8     public partial class PieChartExample : Form
 9     {
10         public PieChartExample()
11         {
12             InitializeComponent();
13  
14             Func<ChartPoint, string> labelPoint = chartPoint =>
15                 string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
16  
17             pieChart1.Series = new SeriesCollection
18             {
19                 new PieSeries
20                 {
21                     Title = "Maria",
22                     Values = new ChartValues<double> {3},
23                     PushOut = 15,
24                     DataLabels = true,
25                     LabelPoint = labelPoint
26                 },
27                 new PieSeries
28                 {
29                     Title = "Charles",
30                     Values = new ChartValues<double> {4},
31                     DataLabels = true,
32                     LabelPoint = labelPoint
33                 },
34                 new PieSeries
35                 {
36                     Title = "Frida",
37                     Values = new ChartValues<double> {6},
38                     DataLabels = true,
39                     LabelPoint = labelPoint
40                 },
41                 new PieSeries
42                 {
43                     Title = "Frederic",
44                     Values = new ChartValues<double> {2},
45                     DataLabels = true,
46                     LabelPoint = labelPoint
47                 }
48             };
49  
50             pieChart1.LegendLocation = LegendLocation.Bottom;
51         }
52     }
53 }

Doughnut

 

 1 using System.Windows.Forms;
 2 using LiveCharts;
 3 using LiveCharts.Wpf;
 4  
 5 namespace Winforms.PieChart
 6 {
 7     public partial class DoughnutExample : Form
 8     {
 9         public DoughnutExample()
10         {
11             InitializeComponent();
12  
13             pieChart1.InnerRadius = 100;
14             pieChart1.LegendLocation = LegendLocation.Right;
15  
16             pieChart1.Series = new SeriesCollection
17             {
18                 new PieSeries
19                 {
20                     Title = "Chrome",
21                     Values = new ChartValues<double> {8},
22                     PushOut = 15,
23                     DataLabels = true
24                 },
25                 new PieSeries
26                 {
27                     Title = "Mozilla",
28                     Values = new ChartValues<double> {6},
29                     DataLabels = true
30                 },
31                 new PieSeries
32                 {
33                     Title = "Opera",
34                     Values = new ChartValues<double> {10},
35                     DataLabels = true
36                 },
37                 new PieSeries
38                 {
39                     Title = "Explorer",
40                     Values = new ChartValues<double> {4},
41                     DataLabels = true
42                 }
43             };
44         }
45     }
46 }

Line

 

 1 using System;
 2 using System.Windows.Forms;
 3 using System.Windows.Media;
 4 using LiveCharts;
 5 using LiveCharts.Wpf;
 6  
 7 namespace Winforms.Cartesian.BasicLine
 8 {
 9     public partial class BasicLineExample : Form
10     {
11         public BasicLineExample()
12         {
13             InitializeComponent();
14  
15             cartesianChart1.Series = new SeriesCollection
16             {
17                 new LineSeries
18                 {
19                     Title = "Series 1",
20                     Values = new ChartValues<double> {4, 6, 5, 2, 7}
21                 },
22                 new LineSeries
23                 {
24                     Title = "Series 2",
25                     Values = new ChartValues<double> {6, 7, 3, 4, 6},
26                     PointGeometry = null
27                 },
28                 new LineSeries
29                 {
30                     Title = "Series 2",
31                     Values = new ChartValues<double> {5, 2, 8, 3},
32                     PointGeometry = DefaultGeometries.Square,
33                     PointGeometrySize = 15
34                 }
35             };
36  
37             cartesianChart1.AxisX.Add(new Axis
38             {
39                 Title = "Month",
40                 Labels = new[] {"Jan", "Feb", "Mar", "Apr", "May"}
41             });
42  
43             cartesianChart1.AxisY.Add(new Axis
44             {
45                 Title = "Sales",
46                 LabelFormatter = value => value.ToString("C")
47             });
48  
49             cartesianChart1.LegendLocation = LegendLocation.Right;
50  
51             //modifying the series collection will animate and update the chart
52             cartesianChart1.Series.Add(new LineSeries
53             {
54                 Values = new ChartValues<double> { 5, 3, 2, 4, 5 },
55                 LineSmoothness = 0, //straight lines, 1 really smooth lines
56                 PointGeometry = Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"),
57                 PointGeometrySize = 50,
58                 PointForeground = Brushes.Gray
59             });
60  
61             //modifying any series values will also animate and update the chart
62             cartesianChart1.Series[2].Values.Add(5d);
63  
64  
65             cartesianChart1.DataClick += CartesianChart1OnDataClick;
66         }
67  
68         private void CartesianChart1OnDataClick(object sender, ChartPoint chartPoint)
69         {
70             MessageBox.Show("You clicked (" + chartPoint.X + "," + chartPoint.Y + ")");
71         }
72     }
73 }

Column

 

 1 using System.Windows.Forms;
 2 using LiveCharts;
 3 using LiveCharts.Wpf;
 4  
 5 namespace Winforms.Cartesian.BasicBar
 6 {
 7     public partial class BasicColumnExample : Form
 8     {
 9         public BasicColumnExample()
10         {
11             InitializeComponent();
12  
13             cartesianChart1.Series = new SeriesCollection
14             {
15                 new ColumnSeries
16                 {
17                     Title = "2015",
18                     Values = new ChartValues<double> { 10, 50, 39, 50 }
19                 }
20             };
21  
22             //adding series will update and animate the chart automatically
23             cartesianChart1.Series.Add(new ColumnSeries
24             {
25                 Title = "2016",
26                 Values = new ChartValues<double> { 11, 56, 42 }
27             });
28  
29             //also adding values updates and animates the chart automatically
30             cartesianChart1.Series[1].Values.Add(48d);
31  
32             cartesianChart1.AxisX.Add(new Axis
33             {
34                 Title = "Sales Man",
35                 Labels = new[] {"Maria", "Susan", "Charles", "Frida"}
36             });
37  
38             cartesianChart1.AxisY.Add(new Axis
39             {
40                 Title = "Sold Apps",
41                 LabelFormatter = value => value.ToString("N")
42             });
43  
44         }
45     }
46 }

Stacked Column

 

 1 using System.Windows.Forms;
 2 using LiveCharts;
 3 using LiveCharts.Wpf;
 4  
 5 namespace Winforms.Cartesian.Basic_Stacked_Column
 6 {
 7     public partial class BasicStackedColumnExample : Form
 8     {
 9         public BasicStackedColumnExample()
10         {
11             InitializeComponent();
12  
13             cartesianChart1.Series = new SeriesCollection
14             {
15                 new StackedColumnSeries
16                 {
17                     Values = new ChartValues<double> {4, 5, 6, 8},
18                     StackMode = StackMode.Values, // this is not necessary, values is the default stack mode
19                     DataLabels = true
20                 },
21                 new StackedColumnSeries
22                 {
23                     Values = new ChartValues<double> {2, 5, 6, 7},
24                     StackMode = StackMode.Values,
25                     DataLabels = true
26                 }
27             };
28  
29             //adding series updates and animates the chart
30             cartesianChart1.Series.Add(new StackedColumnSeries
31             {
32                 Values = new ChartValues<double> {6, 2, 7},
33                 StackMode = StackMode.Values
34             });
35  
36             //adding values also updates and animates
37             cartesianChart1.Series[2].Values.Add(4d);
38  
39             cartesianChart1.AxisX.Add(new Axis
40             {
41                 Title = "Browser",
42                 Labels = new[] {"Chrome", "Mozilla", "Opera", "IE"},
43                 Separator = DefaultAxes.CleanSeparator
44             });
45  
46             cartesianChart1.AxisY.Add(new Axis
47             {
48                 Title = "Usage",
49                 LabelFormatter = value => value + " Mill"
50             });
51  
52         }
53     }
54 }

Row

 

 1 using System.Windows.Forms;
 2 using LiveCharts;
 3 using LiveCharts.Wpf;
 4  
 5 namespace Winforms.Cartesian.BasicBar
 6 {
 7     public partial class BasicRowExample : Form
 8     {
 9         public BasicRowExample()
10         {
11             InitializeComponent();
12  
13             cartesianChart1.Series = new SeriesCollection
14             {
15                 new RowSeries
16                 {
17                     Title = "2015",
18                     Values = new ChartValues<double> { 10, 50, 39, 50 }
19                 }
20             };
21  
22             //adding series will update and animate the chart automatically
23             cartesianChart1.Series.Add(new RowSeries
24             {
25                 Title = "2016",
26                 Values = new ChartValues<double> { 11, 56, 42 }
27             });
28  
29             //also adding values updates and animates the chart automatically
30             cartesianChart1.Series[1].Values.Add(48d);
31  
32             cartesianChart1.AxisY.Add(new Axis
33             {
34                 Labels = new[] { "Maria", "Susan", "Charles", "Frida" }
35             });
36  
37             cartesianChart1.AxisX.Add(new Axis
38             {
39                 LabelFormatter = value => value.ToString("N")
40             });
41  
42             var tooltip = new DefaultTooltip
43             {
44                 SelectionMode = TooltipSelectionMode.SharedYValues
45             };
46  
47             cartesianChart1.DataTooltip = tooltip;
48  
49         }
50     }
51 }

 

标签:基本,控件,Title,cartesianChart1,ChartValues,Values,new,using,LiveCharts
From: https://www.cnblogs.com/davisdabing/p/17834741.html

相关文章

  • 性能理论-软件性能的基本指标(三)
    性能测试指标细分为业务指标、资源指标、应用指标、前端指标。业务指标并发用户数、TPS(系统每秒处理事务数)、成功率、响应时间资源指标CPU资源利用率、内存利用率、I/O应用指标空闲线程数、数据库连接数、GC/FULLGC次数、函数耗时等。前端指标页面加载时间,网络......
  • js基本语法规范
    1.在js中,双引号引起来的,就是字符串。2.JavaScript中的变量变量可以由任意顺序的大小美元符号$组成,但不能以数字开头,,不能是JavaScript中的保留关键字合法标识符举例:indentifier、username、user_name、_userName、$username非法的标识符举例:int、98.3、Helloworld3.JaveScrip......
  • 计算机三大基本原则
    问题  Q1:硬件和软件区别是什么?  A1:硬件是可以看见的实物,软件是看不见的、虚拟的计算机执行的程序,是指令和数据的集合。  Q2:存储字符串“中国”需要几个字节?  A2:在GBK编码下,“中国”需要4字节,在UTF-8编码下,“中国”需要6字节。  Q3:编码是什么?  A3:将非数......
  • 操作系统锁的基本认识
    一、互斥锁和自旋锁互斥锁:​ 最底层的两种就是会「互斥锁和自旋锁」,有很多高级的锁都是基于它们实现的,可以认为它们是各种锁的地基,所以我们必须清楚它俩之间的区别和应用。​ 加锁的目的就是保证共享资源在任意时间里,只有一个线程访问,这样就可以避免多线程导致共享数据错乱的问......
  • 【Python_Django】Django_高级的Python Web框架的基本使用
    Django是一个高级的PythonWeb框架,可以快速开发安全和可维护的网站。由经验丰富的开发者构建,Django负责处理网站开发中麻烦的部分,可以专注于编写应用程序,而无需重新开发准备环境win64系统python3.9Django4.2.6pycharm2021.2.1 创建Django项目1、新......
  • 02-本地库基本操作
    02-本地库基本操作本地库基本操作在一指定文件夹右键使用"gitbush"指令打开git命令行工具,即可进行本地库操作。1.本地库初始化在当前文件夹中初始化git工具环境。$gitinit生成一个.git隐藏文件夹,目录中存放的是本地库相关的子目录和文件,不能随意删除和修改。2......
  • 《最新出炉》系列初窥篇-Python+Playwright自动化测试-28-处理日历时间控件-上篇
    1.简介我们在实际工作中,有可能遇到有些web产品,网页上有一些时间选择,然后支持按照不同时间段范围去筛选数据,例如:我们预定火车票或者预定酒店,需要选择发车日期或者酒店的入住与退房时间。宏哥早在之前的12306选出发站就简单的提到过,只不过是一带而过,今天就展开详细介绍一下。网页上......
  • 界面控件Kendo UI for jQuery R3 2023 - 发布全新金字塔图表类型
    Telerik & KendoUI R32023版本带来了30多个新的UI组件,丰富的设计系统文档、多种自定义选项、支持Linux的现代化报表体验等。借助R32023,开发人员能够在现代框架上快速构建强大的数字体验功能,满足不断变化的业务需求等。今天将为大家主要介绍KendoUIforjQuery R32023的一......
  • DevExpress WinForms HeatMap组件,一个高度可自定义热图控件!
    通过DevExpressWinForms可以为WindowsForms桌面平台提供的高度可定制的热图UI组件,体验DevExpress的不同之处。DevExpressWinForms有180+组件和UI库,能为WindowsForms平台创建具有影响力的业务解决方案。同时能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还......
  • 数据库操作入门:PyMongo 和 MongoDB 的基本用法
    MongoDBMongoDB是一种流行的NoSQL数据库,它将数据存储在类似JSON的文档中,使数据库非常灵活和可扩展PyMongoPython需要一个MongoDB驱动程序来访问MongoDB数据库。在本教程中,我们将使用MongoDB驱动程序"PyMongo"。建议使用PIP来安装"PyMongo",确保您的Python环境已安装PIP。在命......