public void AddDataToChart(string request, List<TimeSpan> runtimes, List<TimeSpan> aggregateRuntimes) { if (_individualRuntimeChart.Legends.FindByName(request) == null) _individualRuntimeChart.Legends.Add(request); _individualRuntimeChart.Series.Add(request); _individualRuntimeChart.Series[_index].ChartType = SeriesChartType.Line; var milliseconds = runtimes.Select(x => x.TotalMilliseconds).ToList(); var trialNum = 0; var trials = milliseconds.Select(item => ++trialNum).ToList(); //_runtimes.Clear(); _runtimes.AddRange(runtimes); _individualRuntimeChart.Series[_index].Points.DataBindXY(trials, "Runs", milliseconds, "Runtime (Milliseconds)"); _individualRuntimeChart.Legends[_index].LegendStyle = LegendStyle.Table; _individualRuntimeChart.Legends[_index].TableStyle = LegendTableStyle.Tall; _individualRuntimeChart.Legends[_index].Docking = Docking.Bottom; _individualRuntimeChart.ChartAreas[0].AxisY.Minimum = aggregateRuntimes.Min().TotalMilliseconds; _individualRuntimeChart.ChartAreas[0].AxisY.Maximum = aggregateRuntimes.Max().TotalMilliseconds; _individualRuntimeChart.ChartAreas[0].AxisX.Minimum = trials.Min(); _individualRuntimeChart.ChartAreas[0].AxisX.Maximum = trials.Max(); _cumulativeRuntimeChart.Legends.Add(request); _cumulativeRuntimeChart.Series.Add(request); _cumulativeRuntimeChart.Series[_index].ChartType = SeriesChartType.Line; var cumulativeMilliseconds = new List<double> { 0 }; cumulativeMilliseconds.AddRange(GetAggregate(runtimes).ToList()); trialNum = 0; trials = cumulativeMilliseconds.Select(item => trialNum++).ToList(); _cumulativeRuntimeChart.Series[_index].Points.DataBindXY(trials, "Runs", cumulativeMilliseconds, "Runtime (Milliseconds)"); _cumulativeRuntimeChart.Legends[_index].LegendStyle = LegendStyle.Table; _cumulativeRuntimeChart.Legends[_index].TableStyle = LegendTableStyle.Tall; _cumulativeRuntimeChart.Legends[_index].Docking = Docking.Bottom; _cumulativeRuntimeChart.ChartAreas[0].AxisY.Minimum = 0; _cumulativeRuntimeChart.ChartAreas[0].AxisY.Maximum = cumulativeMilliseconds.Max(); _cumulativeRuntimeChart.ChartAreas[0].AxisX.Minimum = 0; _cumulativeRuntimeChart.ChartAreas[0].AxisX.Maximum = trials.Max(); if (_runtimeDistributionChart.Series.Count == 0) _runtimeDistributionChart.Series.Add("Distribution"); _runtimeDistributionChart.Series[0].ChartType = SeriesChartType.Column; var ssvm = new StatSummaryViewModel("Distribution", _runtimes); _runtimeDistributionChart.ChartAreas[0].AxisX.Minimum = ssvm.Mean - 3 * ssvm.StdDev; _runtimeDistributionChart.ChartAreas[0].AxisX.Maximum = ssvm.Mean + 3 * ssvm.StdDev; var xValues = new List<double>(); var yValues = new List<int>(); for (var x = _runtimeDistributionChart.ChartAreas[0].AxisX.Minimum + (0.3 * ssvm.StdDev); x <= _runtimeDistributionChart.ChartAreas[0].AxisX.Maximum; x += (0.3 * ssvm.StdDev)) { xValues.Add(x); yValues.Add(_runtimes.Count(y => y.TotalMilliseconds <= x && y.TotalMilliseconds > x - (0.3 * ssvm.StdDev))); } _runtimeDistributionChart.ChartAreas[0].AxisY.Minimum = 0; _runtimeDistributionChart.ChartAreas[0].AxisY.Maximum = yValues.Max(); _runtimeDistributionChart.Series[0].Points.DataBindXY(xValues, "Runtime (Milliseconds)", yValues, "Frequency"); _index++; }
public StatSummaryControl(StatSummaryViewModel viewModel) { InitializeComponent(); ViewModel = viewModel; }