返回首页

如何使ZedGraph清楚!!|我在我的程序中使用zedgraph,它工作良好,当我载入我它。但是当我点击录制按钮,只要插入其他信息,所以图中重复相同的信息酒吧,所以我想清楚之前,我记录或从数据库中删除任何信息。
请帮我

			try {

			

				// get a reference to the GraphPane

				GraphPane myPane = zg1.GraphPane;

				

				// Set the Titles

	myPane.Title.Text = "Les locations enregistrees dans la base de donn茅e";

	myPane.XAxis.Title.Text = "Les Locations";

	myPane.YAxis.Title.Text = "La dur茅e du location & Prix du location";

 

				// Make up some data points

				int iNbLocations = 0;

			_bd.Command.CommandText = "SELECT COUNT(*) FROM locations";

				Debug.WriteLine( Environment.NewLine );

				Debug.WriteLine( _bd.Command.CommandText );

				_bd.Reader = _bd.Command.ExecuteReader();

				if (_bd.Reader.Read()) {

				iNbLocations = int.Parse(_bd.Reader[0].ToString());

				}//if

				_bd.Reader.Close();

				//Max = 5

				if (iNbLocations > 5) {

					iNbLocations = 5;

				}//if

			//Initialisation de la taille des tableaux des donn茅es

				string[] labels = new string[iNbLocations];

				double[] y = new double[iNbLocations];

				double[] y2 = new double[iNbLocations];

                        _bd.Command.CommandText = "SELECT NbJourLocation,"+

                        "DateLocation, idLocations, PrixLocation " +

			"FROM Locations ORDER BY Idlocations desc LIMIT 5";

 

			Debug.WriteLine( Environment.NewLine );

			Debug.WriteLine( _bd.Command.CommandText );

			_bd.Reader = _bd.Command.ExecuteReader();

			for (int i=0; i<inblocations;i++)

	                    if(_bd.Reader.Read()) {

						

		labels[i] = _bd.Reader["idLocations"].ToString();

		y[i] = double.Parse(_bd.Reader["NbJourLocation"].ToString());

		y2[i] = double.Parse(_bd.Reader["PrixLocation"].ToString());

						

				}//if

					

			}//for i

			_bd.Reader.Close();

 

			// Generate a red bar with "Curve 1" in the legend

   BarItem myBar = myPane.AddBar(  "Nombres des Jours du Location", null, y,

				                          Color.GreenYellow );

	   myBar.Bar.Fill = new Fill( Color.Red, Color.Azure,

				                          Color.Red );

				

		// Generate a blue bar with "Curve 2" in the legend

		myBar = myPane.AddBar( "Prix Location", null, y2, Color.Blue );

		myBar.Bar.Fill = new Fill( Color.Blue, Color.White,

				                          Color.Blue );

 

				

				

		// Draw the X tics between the labels instead of

		// at the labels

		myPane.XAxis.MajorTic.IsBetweenLabels = true;

 

		// Set the XAxis labels

		myPane.XAxis.Scale.TextLabels = labels;

		// Set the XAxis to Text type

		myPane.XAxis.Type = AxisType.Text;

		// Fill the Axis and Pane backgrounds

		myPane.Chart.Fill = new Fill( Color.White,

				           Color.FromArgb( 255, 255, 166), 90F );

		myPane.Fill = new Fill( Color.FromArgb( 250, 250, 255) );

				

				

 

		}//try

	catch (Exception ex) {

		Debug.WriteLine( Environment.NewLine );

		Debug.WriteLine( ex.Message );

			MessageBox.Show("Une erreur a 茅t茅 d茅tect茅e : " +

				   Environment.NewLine + ex.Message, "Erreur");

		}

 

		// Tell ZedGraph to refigure the

		// axes since the data have changed

 

		zg1.AxisChange();

回答

评论会员: 时间:2