在Visual Studio中绘制图表

时间:2012-03-20 07:27:38

标签: c# charts zedgraph

我在Visual Studio中使用C#的新手。我想绘制存储为* .dta文件的数据集。我现在可以阅读tat文件,并同样绘制它......

        zg1.Dock = DockStyle.Fill;
        GraphPane myPane = zg1.GraphPane; //ref to graph contol

        double[] y = new double[5000];
        double[] x = new double[5000];

        int i;
        myPane.Title.Text = "C_F_P_D";
        myPane.XAxis.Title.Text = "Time in hr";
        myPane.YAxis.Title.Text = "No";


        FileStream file1 = new FileStream(filename, FileMode.Open, FileAccess.Read);
        BinaryReader binread = new BinaryReader(file1);
        for (i = 0; i < 100; i++)
        {
            fileread = binread.Read();
            y[i] = sensor(Convert.ToChar(fileread));
            x[i] = i;
            //list.Add(fileread[i], i);
        }
        PointPairList list = new PointPairList(x, y);       
        BarItem mybar = myPane.AddBar("test", list, Color.Blue);               // AddingNewEventArgs (x,y) to bar
        mybar.Bar.Fill = new Fill(Color.Blue, Color.White, Color.Blue, 0f);     // giving 3d feel to the bar


        //format Xaxis
        XAxis X = myPane.XAxis;
        X.Scale.MajorStepAuto = false;
        X.Scale.MinorStepAuto = false;
        X.Scale.MajorUnit = DateUnit.Day;
        X.Scale.MinorUnit = DateUnit.Hour;

        X.Scale.MajorStep = 23;
        X.Scale.BaseTic = 0;



        zg1.AxisChange();                           //Invalidate();
    }

我想要的是以条形图或堆积条形图样式将这些数据值绘制为日期(x轴)与时间(0-23小时)。

0 个答案:

没有答案