1. 程式人生 > >LiveChart的用法三(折線圖)

LiveChart的用法三(折線圖)

//第一條 虛線  cartesianChart1.Series.Add(new LineSeries             {                 Values = new ChartValues<double> { 3, 4, 6, 3, 2, 6 },    //直接給幾個值                 StrokeThickness = 4,                        //線的寬度                 StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 2 }),  //應該是設定虛線每段長2象素                 Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(107, 185, 69)),  //線的顏色                 Fill = System.Windows.Media.Brushes.Transparent,                        //填充設定                 LineSmoothness = 0,                                            //線條平滑度                 PointGeometrySize = 0                                           //點的大小為0,(不顯示點)             }); //第二條 實線   cartesianChart1.Series.Add(new LineSeries             {                 Values = new ChartValues<double> { 5, 3, 5, 7, 3, 9 },                 StrokeThickness = 2,                 Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(28, 142, 196)),                 Fill = System.Windows.Media.Brushes.Transparent,                 LineSmoothness = 1,  //線條平滑度                 PointGeometrySize = 15,    //點的大小                 PointForeground =                     new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49))  //點的顏色(內部)             });   //設定背景顏色  cartesianChart1.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49)); //新增x與y軸    cartesianChart1.AxisX.Add(new Axis             {                 IsMerged = true,                 Separator = new Separator                 {                       step=1, //步數                     StrokeThickness = 1,//線寬                     StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 2 }), //虛線2象素                     Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86))  //線的顏色                 }             });             cartesianChart1.AxisY.Add(new Axis             {                 IsMerged = true,                 Separator = new Separator                 {                     StrokeThickness = 1.5,                     StrokeDashArray = new System.Windows.Media.DoubleCollection(new double[] { 4 }),                     Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(64, 79, 86))                 }             });