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