Advertisement
Guest User

graph

a guest
Aug 26th, 2014
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.82 KB | None | 0 0
  1. public class Graph
  2.     {
  3.         public Panel panel;
  4.         public Label name;
  5.         public Label value;
  6.         private Chart chart;
  7.  
  8.         public Graph()
  9.         {
  10.             panel = forms.CHelper.mkC<Panel>("", 540, 30, 302, 225);
  11.             panel.BackColor = Color.FromArgb(150, 200, 255);
  12.             panel.BorderStyle = BorderStyle.FixedSingle;
  13.             name = forms.CHelper.mkC<Label>("", 3, 3, 80, 20);
  14.             name.Text = "Volt";
  15.             panel.Controls.Add(name);
  16.             value = forms.CHelper.mkC<Label>("", 103, 3, 150, 20);
  17.             value.Text = "421321.432 ( OK)";
  18.             panel.Controls.Add(value);
  19.             Label l = forms.CHelper.mkC<Label>("", 250, 3, 80, 20);
  20.             l.Text = "OPT";
  21.             panel.Controls.Add(l);
  22.             double[] yValues = { 1, 0, 0, 1, 2, 3, 0 };
  23.             string[] xValues = { "", "", "", "", "", "", "" };
  24.             double[] yValues2 = { -2, -2, -2, -2, -2, -2, -2 };
  25.             string[] xValues2 = { "", "", "", "", "", "", "" };
  26.             chart = new Chart();
  27.  
  28.  
  29.             Series series = new Series();
  30.             series.ChartType = SeriesChartType.StackedArea;
  31.             series.Color = Color.FromArgb(140, 255, 0, 0);
  32.             series.BorderWidth = 1;
  33.             chart.Series.Add(series);
  34.  
  35.  
  36.             series = new Series();
  37.             series.ChartType = SeriesChartType.StepLine;
  38.             series.Color = Color.FromArgb(0, 0, 0);
  39.             chart.Series.Add(series);
  40.  
  41.             chart.Series[1].Points.DataBindXY(xValues, yValues);
  42.  
  43.             chart.Series[0].Points.DataBindXY(xValues2, yValues2);
  44.  
  45.             ChartArea chartArea = new ChartArea();
  46.             Axis yAxis = new Axis(chartArea, AxisName.Y);
  47.             Axis xAxis = new Axis(chartArea, AxisName.X);
  48.             chart.ChartAreas.Add(chartArea);
  49.             chart.ChartAreas[0].BackColor = Color.FromArgb(180, 255, 255, 255);
  50.             chart.ChartAreas[0].AxisY.Maximum = 8;
  51.             chart.ChartAreas[0].AxisY.Minimum = -2;
  52.             chart.ChartAreas[0].AxisY.Interval = 2;
  53.             chart.ChartAreas[0].AxisX.Minimum = 1;
  54.  
  55.             chart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
  56.             chart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Solid;
  57.             chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(100, 0, 0, 0);
  58.             chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(100, 0, 0, 0);
  59.             chart.ChartAreas[0].AxisY.LineColor = Color.FromArgb(100, 0, 0, 0);
  60.             chart.ChartAreas[0].AxisX.LineColor = Color.FromArgb(100, 0, 0, 0);
  61.  
  62.             chart.Size = new Size(310, 200);
  63.             chart.Location = new Point(-5, 24);
  64.             chart.BackColor = Color.Transparent;
  65.             panel.Controls.Add(chart);
  66.  
  67.         }
  68.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement