using LiveCharts.Wpf; using LiveCharts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace LiveChartPractice { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void btnSeriesAdd_Click(object sender, RoutedEventArgs e) { SampleData data = this.DataContext as SampleData; if (data == null) return; Random rand = new Random(); data.SeriesCollection.Add(new LineSeries { Title = $"Series {data.SeriesCollection.Count + 1}", Values = new ChartValues { rand.Next(1, 8), rand.Next(1, 8), rand.Next(1, 8), rand.Next(1, 8), rand.Next(1, 8) }, LineSmoothness = rand.Next(0, 2), //0: straight lines, 1: really smooth lines //PointGeometry = Geometry.Parse("m 25 70.36218 20 -28 -20 22 -8 -6 z"), //PointGeometrySize = 50, //PointForeground = Brushes.Gray }); } } }