i am using zedgraph in my program, it works good, when i load my it. but when i click on record button so as to insert other information, so the graph duplicated its bars for the same information, so i want to make it clear before i record or delete any information from database.
PLEASE help me
try {
GraphPane myPane = zg1.GraphPane;
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";
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());
}
_bd.Reader.Close();
if (iNbLocations > 5) {
iNbLocations = 5;
}
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());
}
}
_bd.Reader.Close();
BarItem myBar = myPane.AddBar( "Nombres des Jours du Location", null, y,
Color.GreenYellow );
myBar.Bar.Fill = new Fill( Color.Red, Color.Azure,
Color.Red );
myBar = myPane.AddBar( "Prix Location", null, y2, Color.Blue );
myBar.Bar.Fill = new Fill( Color.Blue, Color.White,
Color.Blue );
myPane.XAxis.MajorTic.IsBetweenLabels = true;
myPane.XAxis.Scale.TextLabels = labels;
myPane.XAxis.Type = AxisType.Text;
myPane.Chart.Fill = new Fill( Color.White,
Color.FromArgb( 255, 255, 166), 90F );
myPane.Fill = new Fill( Color.FromArgb( 250, 250, 255) );
}
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");
}
zg1.AxisChange();