public BasicLine() { InitializeComponent(); //we create a new SeriesCollection Series = new SeriesCollection(); //create some LineSeries var charlesSeries = new LineSeries { Title = "Charles", Values = new ChartValues<double> {10, 5, 7, 5, 7, 8} }; var jamesSeries = new LineSeries { Title = "James", Values = new ChartValues<double> { 5, 6, 9, 10, 11, 9 } }; //add our series to our SeriesCollection Series.Add(charlesSeries); Series.Add(jamesSeries); //that's it, LiveCharts is ready and listening for your data changes. DataContext = this; }
public HighPerformanceLine() { InitializeComponent(); //First you need to install LiveCharts.Optimizations //from Nuget: //Install-Package LiveCharts.Optimizations //LiveCharts.Optimization contains a class called ChartOptimizations where you can find //algorithms according to your chart type, they also have a good description, indicating //which is the best according to your case, using a wrong algorithm could not display data //to an optimized quality. //var algorithm = ChartOptimizations.Lines.RegularX<double>() // // low quality is the default, but it is really accurate, it could fail only for +-3 pixels // .WithQuality(DataQuality.Low); //create a configuration in this case we will use X as a zero based index, //and Y as the stored value in Series.Values //we will also attach the algorithm we just selected. var config = new SeriesConfiguration<double>() .X((val, index) => index) .Y(val => val); //.HasHighPerformanceMethod(algorithm); //create a SeriesCollection with this configuration Series = new SeriesCollection(config); //create a new line series var line = new LineSeries {Values = new ChartValues<double>()}; //add some random values to test var r = new Random(); var trend = 0d; for (var i = 0; i < 1000000; i++) { if (i%1000 == 0) trend += r.Next(-500, 500); line.Values.Add(trend + r.Next(-10, 10)); } Series.Add(line); //some format var now = DateTime.Now.ToOADate(); XFormat = val => DateTime.FromOADate(now + val/100).ToShortDateString(); YFormat = val => Math.Round(val) + " ms"; //set zooming if needed. ZoomingMode = ZoomingOptions.XY; DataContext = this; }
public void SharedSeries() { var sharedSeries = new LineSeries {Values = new ChartValues<double> {1, 2, 3}}; var lineChart1 = new BarChart { Series = new SeriesCollection { sharedSeries } }; lineChart1.UnsafeUpdate(); var lineChart2 = new LineChart { Series = new SeriesCollection { sharedSeries } }; lineChart2.UnsafeUpdate(); }
public BasicLine() { InitializeComponent(); Series = new SeriesCollection(); var charlesSeries = new LineSeries { Title = "Charles", Values = new ChartValues<double> {10, 5, 7, 5, 7, 8} }; var jamesSeries = new LineSeries { Title = "James", Values = new ChartValues<double> {5, 6, 9, 10, 11, 9} }; Series.Add(charlesSeries); Series.Add(jamesSeries); DataContext = this; }
public void MyAction() { try { #region Update TxtOutput string txtSalida = string.Empty; string txtEntrada = String.Copy(TxtInput); string salto = "\n"; txtEntrada.Replace(salto, ""); double[] data = TxtInput.Split(';').Select(n => Convert.ToDouble(n)).ToArray(); txtSalida += "Minimum: " + data.Minimum(); txtSalida += salto + "Maximum: " + data.Maximum(); txtSalida += salto + "Count: " + data.Count(); txtSalida += salto + "Mean: " + data.Mean(); txtSalida += salto + "Median: " + data.Median(); txtSalida += salto + "Variance: " + data.Variance(); txtSalida += salto + "StandardDeviation: " + data.StandardDeviation(); txtSalida += salto + "MaximumAbsolute: " + data.MaximumAbsolute(); txtSalida += salto + "MinimumAbsolute: " + data.MinimumAbsolute(); TxtOutput = txtSalida; #endregion #region Update Chart Line ChartValues<double> cv = new ChartValues<double>(); cv.AddRange(data); var lineSerie = new LineSeries { Title = "Values", Values = cv, }; //Bug Series.clear() while (series.Count > 0) { series.RemoveAt(series.Count - 1); } series.Add(lineSerie); #endregion } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
public Window1() { InitializeComponent(); TopLeftLimit = new LagTest(); TopRightLimit = new LagTest(); BotLeftLimit = new LagTest(); BotRightLimit = new LagTest(); _r = new Random(); //ok in this case we are plotting the lag of some different servers according to a date //we also need to highlight the max and min values in each test. //notice that the LagTestClass implements IObservableChartPoint //this allows the char to notice when a value changes //Lets define a configuration by default for all the series in the SeriesCollection var defConfig = new SeriesConfiguration<LagTest>() .X(lagTest => lagTest.DateTime.ToOADate()) .Y(lagTest => lagTest.Value); var serverA = new LineSeries { Title = "Server A", Values = new ChartValues<LagTest> { new LagTest {DateTime = DateTime.Now.AddDays(0), Value = _r.Next(0, 100)}, new LagTest {DateTime = DateTime.Now.AddDays(1), Value = _r.Next(0, 100)}, new LagTest {DateTime = DateTime.Now.AddDays(2), Value = _r.Next(0, 100)}, }, Fill = Brushes.Transparent }; var serverB = new LineSeries { Title = "Server B", Values = new ChartValues<LagTest> { new LagTest {DateTime = DateTime.Now.AddDays(0), Value = _r.Next(0, 100)}, new LagTest {DateTime = DateTime.Now.AddDays(1), Value = _r.Next(0, 100)}, new LagTest {DateTime = DateTime.Now.AddDays(2), Value = _r.Next(0, 100)}, }, Fill = Brushes.Transparent }; //to highlight the max and min values, we will also plot 2 more series //every series contains 2 points: max and min _min = new LineSeries { Values = new ChartValues<LagTest> {BotLeftLimit, BotRightLimit}, StrokeThickness = 1, StrokeDashArray = new DoubleCollection {2}, //make it dashed Stroke = Brushes.DarkBlue, Fill = Brushes.Transparent }; _max = new LineSeries { Values = new ChartValues<LagTest> {TopLeftLimit, TopRightLimit}, StrokeThickness = 1, StrokeDashArray = new DoubleCollection {2}, //make it dashed Stroke = Brushes.DarkBlue, Fill = Brushes.Transparent }; Servers = new SeriesCollection(defConfig) { _min, _max, serverA, serverB }; _maxAndMin = new List<Series> {_min, _max}.AsEnumerable(); CalculateLimits(); DateFormatter = val => DateTime.FromOADate(val).ToString("M"); DataContext = this; }
private void OnWindowLoaded(object obj) { // Do Data Initialisation here var bot = DateTime.Today; var eot = bot.AddDays(1); SOSBottom = new ObservablePt() { DateTime = SOS.AddHours(Start + Period), Data = 0 }; SOSTop = new ObservablePt() { DateTime = SOS.AddHours(Start + Period), Data = 3000 }; Start = 9; Period = 2.5; MaxLeft = new ObservablePt() { DateTime = bot, Data = this.MaxStrain }; MaxRight = new ObservablePt() { DateTime = eot, Data = this.MaxStrain }; MinLeft = new ObservablePt() { DateTime = bot, Data = this.MinStrain }; MinRight = new ObservablePt() { DateTime = eot, Data = this.MinStrain }; DateFormatter = val => DateTime.FromOADate(val).ToString("T"); // we create a new SeriesCollection //create some LineSeries maxSeries = new LineSeries { Title = "Max", Values = new ChartValues<ObservablePt> { MaxLeft, MaxRight }, Fill = Brushes.Transparent, Configuration = new SeriesConfiguration<ObservablePt>().X( pt => pt.DateTime.ToOADate()).Y(pt => pt.Data), Stroke = Brushes.Red, StrokeThickness = 1, StrokeDashArray = new DoubleCollection { 2 }, //make it dashed }; minSeries = new LineSeries { Title = "Min", Values = new ChartValues<ObservablePt> { MinLeft, MinRight }, Fill = Brushes.Transparent, Configuration = new SeriesConfiguration<ObservablePt>().X(pt => pt.DateTime.ToOADate()).Y(pt => pt.Data), Stroke = Brushes.Red, StrokeThickness = 1, StrokeDashArray = new DoubleCollection { 2 }, //make it dashed }; periodSeries = new LineSeries { Title = "EOS", Values = new ChartValues<ObservablePt> { SOSBottom, SOSTop }, Fill = Brushes.Transparent, Configuration = new SeriesConfiguration<ObservablePt>().X(pt => pt.DateTime.ToOADate()).Y(pt => pt.Data), Stroke = Brushes.Yellow, StrokeThickness = 1, StrokeDashArray = new DoubleCollection { 2 }, //make it dashed }; //add series to SeriesCollection Series.Add(maxSeries); Series.Add(minSeries); Series.Add(periodSeries); }