bonjour a tous, j'essai de crée une courbe apartir d'un table de base de donnée:
j'utilise le code suivant:
connection.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
id1 = double.Parse(reader.GetString(1));
id2 = double.Parse(reader.GetString(2));
string nDateTime = DateTime.Now.ToString("hh:mm:ss tt");
// Lets generate sine and cosine wave
double[] x = new double[100];
double[] y = new double[100];
double[] z = new double[100];
x[i] = i;
y[i] = Math.Sin(id1);
z[i] = Math.Sin(id2);
i++;
// This is to remove all plots
zedGraphControl1.GraphPane.CurveList.Clear();
// GraphPane object holds one or more Curve objects (or plots)
GraphPane myPane = zedGraphControl1.GraphPane;
// PointPairList holds the data for plotting, X and Y arrays
PointPairList spl1 = new PointPairList(x, y);
PointPairList spl2 = new PointPairList(x, z);
// Add cruves to myPane object
LineItem myCurve1 = myPane.AddCurve("Sine Wave", spl1, Color.Blue, SymbolType.None);
LineItem myCurve2 = myPane.AddCurve("Cosine Wave", spl2, Color.Red, SymbolType.None);
myCurve1.Line.Width = 3.0F;
myCurve2.Line.Width = 3.0F;
myPane.Title.Text = "My First Plot";
// I add all three functions just to be sure it refeshes the plot.
zedGraphControl1.AxisChange();
//myPane.XAxis.Scale.Format = nDateTime;
zedGraphControl1.Invalidate();
zedGraphControl1.Refresh();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "Erreur !bd! ");
}
connection.Close();
le resultat s'affiche comme suit : (capture)
merci .
Partager