private void Button_Click(object sender, RoutedEventArgs e) { wait.Opacity = 1; print.IsEnabled = false; a = after.SelectedDate.ToString(); b = before.SelectedDate.ToString(); mess = new Message(); mess.Add(StendSelected.SelectedValue.ToString()); for (int i = 0; i < projects.Children.Count; i += 2) { CheckBox checkBox = (CheckBox)projects.Children[i]; if (checkBox.IsChecked == true) { mess.Add(checkBox.Name); } } bw = new BackgroundWorker(); bw.DoWork += (obj, ea) => { СreateCharts(); }; bw.RunWorkerAsync(); bw.RunWorkerCompleted += (obj, ea) => { SeriesCollection.Clear(); for (int i = 0; i < tests.Count; i++) { LineSeries lineSeries = new LineSeries() { Title = tests[i], Fill = Brushes.Transparent, PointGeometry = null }; lineSeries.Values = new ChartValues <CustomerVm>(); for (int j = 0; j < results[i].Count; j++) { CustomerVm vm = new CustomerVm { Value = results[i][j] == "" ? double.NaN : double.Parse(results[i][j]), Show = results[i][j] == "" ? "" : tests[i] + ": " + results[i][j] + "c" }; lineSeries.Values.Add(vm); } SeriesCollection.Add(lineSeries); } LineSeries lineSeries1 = new LineSeries(); lineSeries1.Stroke = Brushes.Transparent; lineSeries1.Title = ""; lineSeries1.Values = new ChartValues <CustomerVm>(); SeriesCollection.Add(lineSeries1); Labels.Labels = date; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerVm>() .X((value, index) => index) // lets use the position of the item as X .Y(value => value.Value); //and PurchasedItems property as Y //lets save the mapper globally Charting.For <CustomerVm>(customerVmMapper); DataContext = this; wait.Opacity = 0; print.IsEnabled = true; }; InitializeComponent(); }
public Charts() { InitializeComponent(); hiddenTests = new Dictionary <string, Brush>(); valuesTests = new Dictionary <string, IChartValues>(); SeriesCollection = new SeriesCollection(); Message services = JsonConvert.DeserializeObject <Message>(Data.ServiceName); Message project = JsonConvert.DeserializeObject <Message>(Data.ProjectName); for (var i = 0; project.args.Count > i; i++) { CheckBox checkBox = new CheckBox(); checkBox.Name = services.args[i]; checkBox.Margin = new Thickness( i / 3 * 140, (i * 20) - i / 3 * 60, 0, 0); if (checkBox.Name == Data.ServiceSel) { checkBox.IsChecked = true; } projects.Children.Add(checkBox); TextBlock textBox = new TextBlock(); textBox.Text = project.args[i]; textBox.Margin = new Thickness( i / 3 * 140 + 20, (i * 20) - i / 3 * 60, 20, 20); textBox.Foreground = Brushes.White; projects.Children.Add(textBox); } Message message = JsonConvert.DeserializeObject <Message>(server.SendMsg("GetStends", Data.ServiceSel)); int flag = -1; for (int i = 0; i < message.args.Count; i++) { StendSelected.Items.Add(message.args[i]); if (message.args[i] == Data.StendSel) { flag = i; } } StendSelected.SelectedIndex = flag; a = after.SelectedDate.ToString(); b = before.SelectedDate.ToString(); mess = new Message(); mess.Add(StendSelected.SelectedValue.ToString()); for (int i = 0; i < projects.Children.Count; i += 2) { CheckBox checkBox = (CheckBox)projects.Children[i]; if (checkBox.IsChecked == true) { mess.Add(checkBox.Name); } } bw = new BackgroundWorker(); bw.DoWork += (obj, ea) => { СreateCharts(); }; bw.RunWorkerAsync(); bw.RunWorkerCompleted += (obj, ea) => { for (int i = 0; i < tests.Count; i++) { LineSeries lineSeries = new LineSeries() { Title = tests[i], Fill = Brushes.Transparent, PointGeometry = null }; lineSeries.Values = new ChartValues <CustomerVm>(); for (int j = 0; j < results[i].Count; j++) { CustomerVm vm = new CustomerVm { Value = results[i][j] == "" ? double.NaN : double.Parse(results[i][j]), Show = results[i][j] == "" ? "" : tests[i] + ": " + results[i][j] + "c" }; lineSeries.Values.Add(vm); } SeriesCollection.Add(lineSeries); } LineSeries lineSeries1 = new LineSeries(); lineSeries1.Stroke = Brushes.Transparent; lineSeries1.Title = ""; lineSeries1.Values = new ChartValues <CustomerVm>(); SeriesCollection.Add(lineSeries1); Labels.Labels = date; //let create a mapper so LiveCharts know how to plot our CustomerViewModel class var customerVmMapper = Mappers.Xy <CustomerVm>() .X((value, index) => index) // lets use the position of the item as X .Y(value => value.Value); //and PurchasedItems property as Y //lets save the mapper globally Charting.For <CustomerVm>(customerVmMapper); DataContext = this; wait.Opacity = 0; }; }