Pages: [1]   Go Down
Author Topic: problem using zedgraph in C#  (Read 1202 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hye everyone,im using the zedgraph to show the real time of water level. the water level range is 0-4.the x axis is the time( every hour).here are the code.
Code:
private void zedGraphControl1_Load(object sender, EventArgs e)
        {
            // pane use to draw the chart
            GraphPane mypane = new GraphPane();
            //point pair list
            PointPairList listPointsOne = new PointPairList();
            PointPairList listPointsTwo = new PointPairList();
            //line item
            LineItem myCurveOne;
            //set the pane
            mypane = zedGraphControl1.GraphPane;
 
            //set the title
            mypane.Title.Text = "Flood Monitoring System\n";
            mypane.Title.IsVisible = true; // show the visibility of the title

            //set the X axis
            mypane.XAxis.Type = AxisType.DateAsOrdinal;
            mypane.XAxis.Scale.Format = "HH:mm:ss";
            mypane.XAxis.Title.Text = "Time";
            mypane.XAxis.MajorGrid.IsVisible = true;
            mypane.XAxis.MinorGrid.IsVisible = true;
            mypane.XAxis.Scale.MajorUnit = DateUnit.Minute;
            mypane.XAxis.Scale.MinorUnit = DateUnit.Minute;
            mypane.XAxis.Title.IsVisible = true;        //show the visibility of x axis title.
            mypane.XAxis.Scale.Min = 0;
            mypane.XAxis.Scale.Max = 24;
            mypane.XAxis.Scale.MajorStep = 1;
            mypane.XAxis.MinorTic.Size = 1;

            //set the Y axis
            mypane.YAxis.Type = AxisType.Linear;
            mypane.YAxis.Title.Text = "Water Level";
            mypane.YAxis.Scale.Format = @"0.0";
            mypane.YAxis.Title.IsVisible = true;
            mypane.YAxis.MajorGrid.IsVisible = true;
            mypane.YAxis.Scale.Min = 0;
            mypane.YAxis.Scale.Max = 4;
            mypane.YAxis.Scale.MajorStep = 1;

         
            //create dummy data
            double[] y = {1,2,3,2,1,4,2,4 };
            double[] x = {0,10,14,16,18,20,22,24};
         

            //add curve to the pane
            myCurveOne = mypane.AddCurve("WaterLevel",x,y,Color.Red,SymbolType.Triangle);

            myCurveOne.Line.Width = 1.0F;
           
            //function that makesure the graph updated automatically
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl1.Refresh();
        }
my problem is that no data is appeared on the graph as well as the axis title and the title of the graph..
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
my problem is that no data is appeared on the graph as well as the axis title and the title of the graph..
Do you mean that no data appeared on the graph except the titles, or do you mean that no data appeared, not even the titles?

How is this an Arduino issue? That code is clearly not running on the Arduino.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 211
Posts: 13477
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


think the problem is that ZED does not know how big x and y are .. somewhere you need to say the arrays contain 8 values.

Do the sample apps of ZED work well? (I assume there are)
these sample apps may have the missing instruction.

(have no zed around sorry;)
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: