Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using System.Windows.Forms.DataVisualization;
  8. using System.Windows.Forms.DataVisualization.Charting;
  9.  
  10. namespace Profiling
  11. {
  12.     public class Type
  13.     {
  14.         public static readonly string Struct = "Struct";
  15.         public static readonly string Class = "Class";
  16.     }
  17.    
  18.     class ChartBuilder : IChartBuilder
  19.     {
  20.         public Series CreateSetPoints(string type)
  21.         {
  22.             Series result = new Series(type);
  23.             result.LegendText = type;
  24.             result.BorderWidth = 2;
  25.             result.ChartType = SeriesChartType.Line;
  26.             result.ChartArea = "Experiment Result";
  27.             return result;
  28.         }
  29.  
  30.         public Control Build(List<ExperimentResult> result)
  31.         {
  32.             Chart myChart = new Chart();
  33.             myChart.Dock = DockStyle.Fill;
  34.             myChart.ChartAreas.Add(new ChartArea("Experiment Result"));
  35.             var pointStruct = CreateSetPoints(Type.Struct);
  36.             var pointClass = CreateSetPoints(Type.Class);
  37.             foreach (var res in result)
  38.             {
  39.                 pointStruct.Points.AddXY(res.Size, res.StructResult);
  40.                 pointClass.Points.AddXY(res.Size, res.ClassResult);
  41.             }
  42.             myChart.Series.Add(pointStruct);
  43.             myChart.Series.Add(pointClass);
  44.             Legend legend = new Legend();
  45.             myChart.Legends.Add(legend);
  46.  
  47.             return myChart;
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement