我需要得到的结果是输入一系列数据,点下BUTTON,然后根据一定的公式计算后跳出相应的曲线图.也许对高手来说这是个很简单的问题.但我现在入门,实在是不知道如何下手.希望高手们能给予解答,或是能给我一些比较详细的实例.小弟在这里先谢谢了.

解决方案 »

  1.   

    这个其实去看看GDI+就好了
    本题的数值计算不是很困难
      

  2.   

    主要是利用GDI+,在System.Drawing命名空间下的类。
      

  3.   

    GDI+
    using System.Drawing;
      

  4.   

    GDI+ 
    using System.Drawing; 
    这个不好说,你的数据要看是什么样的了,柱状,折线,饼的画法网上你可以搜下
      

  5.   

    http://www.cnblogs.com/skyivben/archive/2005/10/26/262133.html
      

  6.   


    // plot.cs: 画函数图形, 编译方法: csc /t:winexe plot.cs 
    using System; 
    using System.Drawing; 
    using System.Windows.Forms; 
     
    namespace Skyiv.Ben.Plot 

      sealed class PlotForm : Form 
      { 
        // 要画的函数,如果能在 TextBox 中输入函数的表达式就更好了 
        double Function(double x) 
        { 
          double u = Math.PI - x; 
          double pi2 = Math.PI * Math.PI; 
          return 3 * x * x + Math.Log(u * u) / pi2 / pi2 + 1; 
        } 
         
        // 仅仅用来显示在屏幕上 
        string FunctionString() 
        { 
          return "f(x) = 3 * x^2 + pi^-4 * ln[(pi-x)^2] + 1"; 
        } 
         
        const int yBase = 24; // 屏幕保留区域的高度 
     
        TextBox tbxX0, tbxX1; // 函数自变量的取值范围 
         
        PlotForm() 
        { 
          SuspendLayout(); 
           
          Button btnSubmit = new Button(); 
          btnSubmit.Text = "刷新"; 
          btnSubmit.Location = new Point(0, 0); 
          btnSubmit.Size = new Size(48, 24); 
          btnSubmit.Click += new EventHandler(BtnSubmit_Click); 
     
          tbxX0 = new TextBox(); 
          tbxX0.Text = "-10"; 
          tbxX0.Location = new Point(55, 3); 
          tbxX0.Size = new Size(150, 20); 
     
          tbxX1 = new TextBox(); 
          tbxX1.Text = "10"; 
          tbxX1.Location = new Point(210, 3); 
          tbxX1.Size = new Size(150, 20); 
     
          Controls.AddRange(new Control[]{btnSubmit, tbxX0, tbxX1}); 
          Text = "Plot"; 
          BackColor = Color.White; 
          ClientSize = new Size(600, 600 + yBase); 
          // WindowState = FormWindowState.Maximized; 
     
          ResumeLayout(false); 
        } 
     
        void BtnSubmit_Click(object sender, EventArgs e) 
        { 
          Invalidate(); 
        } 
         
        protected override void OnSizeChanged(EventArgs e) 
        { 
          Invalidate(); 
          base.OnSizeChanged(e); 
        } 
         
        protected override void OnPaint(PaintEventArgs e) 
        { 
          double x0 = double.Parse(tbxX0.Text); 
          double x1 = double.Parse(tbxX1.Text); 
          Graphics gc = e.Graphics; 
          Size size = ClientSize; 
          int i0 = 0; 
          int i1 = size.Width - 1; 
          int j0 = yBase; 
          int j1 = size.Height - 1; 
          Pen pen = new Pen(Color.Black, 1); 
          gc.DrawLine(pen, i0, j0, i1, j0); // 画图区和保留区的分界线 
          double rx = (x1 - x0) / (i1 - i0); 
          double y0, y1; 
          GetFunctionValueRange(x0, rx, i0, i1, out y0, out y1); 
          double ry = (y1 - y0) / (j1 - j0); 
          Out(gc, 0, "ClientSize: {0}x{1}", i1 - i0 + 1, j1 - j0 + 1); 
          Out(gc, 1, FunctionString()); 
          Out(gc, 2, "x:[{0}, {1}] range:{2}", x0, x1, x1 - x0); 
          Out(gc, 3, "y:[{0}, {1}] range:{2}", y0, y1, y1 - y0); 
          Out(gc, 4, "rx:{0}", 1 / rx);  // 函数自变量每单位值用多少个象素表示 
          Out(gc, 5, "ry:{0}", 1 / ry);  // 函数的值每单位值用多少个象素表示 
          Out(gc, 6, "r :{0}", rx / ry); // 该值如果小于1表示图形纵向被压扁,反之则被拉伸 
          pen.Color = Color.Green; 
          int j = j1 + (int)(y0 / ry); 
          if (j >= j0 && j <= j1) gc.DrawLine(pen, i0, j, i1, j); // x坐标轴 
          int i = i0 - (int)(x0 / rx); 
          if (i >= i0 && i <= i1) gc.DrawLine(pen, i, j0, i, j1); // y坐标轴 
          pen.Color = Color.Red; 
          for (i = i0; i <= i1; i++) 
          { 
            double x = x0 + (i - i0) * rx; 
            double y = Function(x); 
            if (double.IsInfinity(y) || double.IsNaN(y)) continue; 
            j = j1 - (int)((y - y0) / ry); 
            if (j > j1 || j < j0) continue; 
            gc.DrawLine(pen, i, j, i + 1, j); // 画函数的图形 
          } 
          base.OnPaint(e); 
        } 
         
        // 函数值的取值范围 
        void GetFunctionValueRange(double x0, double rx, int i0, int i1, out double y0, out double y1) 
        { 
          y0 = double.MaxValue; 
          y1 = double.MinValue; 
          for (int i = i0; i <= i1; i++) 
          { 
            double x = x0 + (i - i0) * rx; 
            double y = Function(x); 
            if (double.IsInfinity(y) || double.IsNaN(y)) continue; 
            if (y0 > y) y0 = y; 
            if (y1 < y) y1 = y; 
          } 
        } 
         
        // 在指定的位置写字符串 
        void Out(Graphics gc, int line, string fmt, params object [] args) 
        { 
          gc.DrawString(string.Format(fmt, args), new Font("Courier New", 10), Brushes.Blue, new PointF(5, yBase + 15 * line)); 
        } 
     
        static void Main() 
        { 
          Application.Run(new PlotForm()); 
        } 
      } 
      

  7.   

    http://www.cnblogs.com/skyivben/archive/2005/11/01/266649.html