Exemple #1
0
        private AxisSetting GetAxisSetting()
        {
            var result = new AxisSetting
            {
                XMin      = GetTextDouble(textBoxXMin.Text, 0),
                XInterval = GetTextDouble(textBoxXInterval.Text, 0.1),
                XMax      = GetTextDouble(textBoxXMax.Text, 1),

                YMin      = GetTextDouble(textBoxYMin.Text, 0),
                YInterval = GetTextDouble(textBoxYInterval.Text, 10),
                YMax      = GetTextDouble(textBoxYMax.Text, 100),

                Width  = (int)GetTextDouble(textBoxWidth.Text, 300),
                Height = (int)GetTextDouble(textBoxHeight.Text, 300),

                ShowLegend = false,
            };

            return(result);
        }
Exemple #2
0
        private static Chart GetChart(IReadOnlyDictionary <string, Dictionary <double, double> > result, string projectName, string methodIName, IEnumerable <string> methodJNames, string metricToUse, AxisSetting axisSetting)
        {
            var namePrefix = projectName + methodIName + metricToUse;

            var chart = new Chart
            {
                Text   = projectName,
                Name   = namePrefix + "Chart",
                Width  = axisSetting.Width,
                Height = axisSetting.Height,
            };

            var chartArea = new ChartArea
            {
                Name = namePrefix + "ChartArea",
            };

            chart.ChartAreas.Add(chartArea);

            var xAxis = new Axis(chartArea, AxisName.X)
            {
                Interval = axisSetting.XInterval,
                Minimum  = axisSetting.XMin,
                Maximum  = axisSetting.XMax
            };

            chartArea.AxisX = xAxis;

            var yAxis = new Axis(chartArea, AxisName.Y)
            {
                Interval = axisSetting.YInterval,
                Minimum  = axisSetting.YMin,
                Maximum  = axisSetting.YMax
            };

            chartArea.AxisY = yAxis;

            foreach (var methodJName in methodJNames)
            {
                var series = new Series()
                {
                    Name              = namePrefix + methodJName + "Series",
                    Color             = GetColor(methodJName),
                    IsVisibleInLegend = true,
                    ChartType         = SeriesChartType.Line,
                };
                foreach (var key in result[methodJName].Keys)
                {
                    series.Points.AddXY(key, result[methodJName][key]);
                }

                if (axisSetting.ShowLegend)
                {
                    chart.Legends.Add(new Legend(methodJName));
                    chart.Legends[methodJName].Docking     = Docking.Top;
                    chart.Legends[methodJName].Alignment   = StringAlignment.Near;
                    chart.Legends[methodJName].LegendStyle = LegendStyle.Column;

                    series.Legend     = methodJName;
                    series.LegendText = methodJName;
                }

                chart.Series.Add(series);
            }

            chart.Titles.Add($"{projectName} - {methodIName}");

            return(chart);
        }