public void AddSeries(Interfaces.IIsChartSeries series) { series.ChangedData += ItemChanged; series.NewData += ItemAdded; series.DataCleared += ItemsCleared; _SeriesSource.Add(series); switch (series.SeriesType) { case "Candle": LiveCharts.Wpf.OhlcSeries chartseries = new LiveCharts.Wpf.OhlcSeries(); chartseries.Title = series.SeriesLabel; chartseries.Values = new LiveCharts.ChartValues <LiveCharts.Defaults.OhlcPoint>(); LiveCharts.Wpf.Axis axis = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axis); chartseries.ScalesYAt = Chart.AxisY.IndexOf(axis); Chart.Series.Add(chartseries); break; case "Line": LiveCharts.Wpf.LineSeries chartseriesline = new LiveCharts.Wpf.LineSeries(); chartseriesline.Title = series.SeriesLabel; chartseriesline.Values = new LiveCharts.ChartValues <double>(); chartseriesline.PointGeometry = null; LiveCharts.Wpf.Axis axisline = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axisline); chartseriesline.ScalesYAt = Chart.AxisY.IndexOf(axisline); Chart.Series.Add(chartseriesline); break; case "Column": LiveCharts.Wpf.ColumnSeries chartseriescolumn = new LiveCharts.Wpf.ColumnSeries(); chartseriescolumn.Title = series.SeriesLabel; chartseriescolumn.Values = new LiveCharts.ChartValues <double>(); LiveCharts.Wpf.Axis axiscolumn = new LiveCharts.Wpf.Axis() { Title = series.YAxisLabel, ShowLabels = true }; Chart.AxisY.Add(axiscolumn); chartseriescolumn.ScalesYAt = Chart.AxisY.IndexOf(axiscolumn); Chart.Series.Add(chartseriescolumn); break; case "Bar": default: break; } }
public void AddToChart(string title, double[] values) { var series = new LiveCharts.Wpf.LineSeries(); series.Title = title; ChartValues <double> chartValues = new ChartValues <double>(); foreach (var c in values) { chartValues.Add(c); } series.Values = chartValues; mySeries.Add(series); }
public static void SetCaresianChartOptimizeError(CartesianChart cartesianChart) { cartesianChart.AxisX.Clear(); cartesianChart.AxisY.Clear(); cartesianChart.Series.Clear(); var chartValues = new ChartValues <double>(); var labels = new List <string>(); foreach (var point in OptimizeErrorPoints) { chartValues.Add(point.Y); labels.Add(point.X.ToString(CultureInfo.InvariantCulture)); } var series = new LiveCharts.Wpf.LineSeries() { Title = "Погрешность", Values = chartValues }; cartesianChart.Series = new SeriesCollection() { series }; cartesianChart.AxisX.Add(new LiveCharts.Wpf.Axis { Title = "Frequency", Labels = labels }); cartesianChart.AxisY.Add(new LiveCharts.Wpf.Axis { Title = "Sales", LabelFormatter = value => value.ToString(CultureInfo.InvariantCulture) }); cartesianChart.LegendLocation = LegendLocation.Right; }
private async void btnLoad_Click(object sender, RoutedEventArgs e) { foreach (var i in Instances) { await i.RunAsync(); await Task.Delay(100); } //totalização da entrada var s1 = new LiveCharts.Wpf.LineSeries() { Title = "Total de Itens", Values = new LiveCharts.ChartValues <int>(Instances.Select(x => x.Items)) }; var s2 = new LiveCharts.Wpf.LineSeries() { Title = "Total de Conflitos", Values = new LiveCharts.ChartValues <int>(Instances.Select(x => x.Conflicts)) }; var sc1 = new LiveCharts.SeriesCollection() { s1, s2 }; ReportEntry r1 = new ReportEntry() { Name = "Itens x Conflitos", Labels = Instances.Select(x => x.Name).ToArray(), SeriesCollection = sc1 }; //tempo de leitura var s3 = new LiveCharts.Wpf.LineSeries() { Title = "Tempo de leitura (ms)", Values = new LiveCharts.ChartValues <double>(Instances.Select(x => x.LoadTime)) }; var sc2 = new LiveCharts.SeriesCollection() { s3 }; ReportEntry r2 = new ReportEntry() { Name = "Tempo gasto para ler o arquivo de entrada", Labels = Instances.Select(x => x.Name).ToArray(), SeriesCollection = sc2 }; //tempo gasto para encontrar uma solução var s4 = new LiveCharts.Wpf.LineSeries() { Title = "Tempo de gasto (ms)", Values = new LiveCharts.ChartValues <double>(Instances.Select(x => x.ExecutionTime)) }; var sc3 = new LiveCharts.SeriesCollection() { s4 }; ReportEntry r3 = new ReportEntry() { Name = "Tempo gasto para gerar uma solução", Labels = Instances.Select(x => x.Name).ToArray(), SeriesCollection = sc3 }; //número de nós explorados var s5 = new LiveCharts.Wpf.LineSeries() { Title = "Nós explorados", Values = new LiveCharts.ChartValues <int>(Instances.Select(x => x.ExploredNodes)) }; var sc4 = new LiveCharts.SeriesCollection() { s5 }; ReportEntry r4 = new ReportEntry() { Name = "Quantidade de nós explorados para gerar uma solução", Labels = Instances.Select(x => x.Name).ToArray(), SeriesCollection = sc4 }; Report r = new Report(); r.Entries = new List <ReportEntry>() { r1, r2, r3, r4 }; ReportWindow rw = new ReportWindow(r); rw.Show(); //var f = cbInstances.SelectedValue as string; //await Task.Run( async () => //{ // var tree = FileReader.ReadFile(f); // tree.Build(); // var total = tree.Count(); // //tree.PruneConflicts(tree.Root); // var total2 = tree.Count(); // var k = tree; // //await App.Current.Dispatcher.InvokeAsync(() => // //{ // // graph.Graph = tree.Root.ToGraphSharp(); // //}); //}); }
public static void SetCaresianChartBeforeAndAfter(CartesianChart cartesianChart, Points[] points) { cartesianChart.AxisX.Clear(); cartesianChart.AxisY.Clear(); cartesianChart.Series.Clear(); OptimizeErrorPoints = new Points[points.Length]; var chartValuesOriginal = new ChartValues <double>(); var chartValuesBeforeOptimization = new ChartValues <double>(); var labels = new List <string>(); var i = -1; foreach (var point in points) { i += 1; chartValuesOriginal.Add(point.Y); var newY = point.Y + Convert.ToDouble(Random.Next(-1, 1)); OptimizeErrorPoints[i] = new Points() { X = point.X, Y = point.Y - newY }; chartValuesBeforeOptimization.Add(newY); //chartValuesBeforeOptimization.Add(); labels.Add(point.X.ToString(CultureInfo.InvariantCulture)); } var seriesOriginal = new LiveCharts.Wpf.LineSeries() { Title = "Желаемая", Values = chartValuesOriginal }; var seriesBeforeOptimization = new LiveCharts.Wpf.LineSeries() { Title = "Действительная", Values = chartValuesBeforeOptimization }; cartesianChart.Series = new SeriesCollection() { seriesOriginal, seriesBeforeOptimization }; cartesianChart.AxisX.Add(new LiveCharts.Wpf.Axis { Title = "Frequency", Labels = labels }); cartesianChart.AxisY.Add(new LiveCharts.Wpf.Axis { Title = "Sales", LabelFormatter = value => value.ToString(CultureInfo.InvariantCulture) }); cartesianChart.LegendLocation = LegendLocation.Right; }
public static List <Tuple <DateTime, double?> > ToNullableTupleList(this LiveCharts.Wpf.LineSeries series) { return(series.Values.Cast <DateModel>().Select(_ => new Tuple <DateTime, double?>(_.DateTime, _.Value)).ToList()); }
public static List <Tuple <DateTime, double> > ToTupleList(this LiveCharts.Wpf.LineSeries series) { return(series.Values.Cast <DateModel>().Select(_ => Tuple.Create(_.DateTime, _.Value)).ToList()); }