20 décembre 2006
3
20
/12
/décembre
/2006
15:14
ChartFx Lite (free)
Avec un dataset typé
chart1.DataType[0] = DataType.NotUsed;
chart1.DataType[1] = DataType.NotUsed;
chart1.DataType[2] = DataType.Value;
chart1.DataType[3] = DataType.Value;
chart1.DataSource = bD_Tests_ChartFxDataSet.PERSONNE;
// DEFINIT TYPE GRAPHIQUE : BAR,AREA,...
chart1.Gallery = Gallery.Bar ;
chart1.SerLegBox = true;
Avec un dataset
System.Data.DataSet ds;
System.Data.OleDb.OleDbConnection cnn;
System.Data.OleDb.OleDbDataAdapter da;
cnn = new System.Data.OleDb.OleDbConnection();
ds = new System.Data.DataSet("PERSONNE");
da = new System.Data.OleDb.OleDbDataAdapter();
da.SelectCommand = new System.Data.OleDb.OleDbCommand();
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Application.StartupPath + @"BASEBD_Tests_ChartFx.mdb;";
da.SelectCommand.Connection = cnn;
da.SelectCommand.CommandType = CommandType.Text;
da.SelectCommand.CommandText = "SELECT N,NOM,AGE,NB from PERSONNE";
da.Fill(ds);
// GRAPHIQUE
chart1.DataType[0] = DataType.NotUsed;
chart1.DataType[1] = DataType.NotUsed;
chart1.DataType[2] = DataType.Value;
chart1.DataType[3] = DataType.Value;
chart1.DataSource = ds.Tables[0];
chart1.Gallery = Gallery.Bar; // DEFINIT TYPE GRAPHIQUE : BAR,AREA,...
chart1.SerLegBox = true;
ASTUCES
Une combobox permettant de sélectionner le type de graphique(Bar,camembert,…)
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
switch(comboBox1.SelectedIndex)
{
case 0:
chart1.Gallery = Gallery.Area; // FORMES PLEINES
break;
case 1:
chart1.Gallery = Gallery.Bar; // BARRES
break;
case 2:
chart1.Gallery = Gallery.Lines;// DROITE
break;
case 3:
chart1.Gallery = Gallery.Pie; // CAMEMBERT
break;
case 4:
chart1.Gallery = Gallery.Scatter; // POINTS
break;
default:
break;
}
}
On peut egalement regler
- Affichage 3D
chart1.Chart3D = true;
- Grille
chart1.AxisX.Gridlines = true;
chart1.AxisX.Grid.Color = Color.Salmon; chart1.AxisY.Gridlines = false;
ou
chart1.Grid = ChartGrid.None;
- supperposé
chart1.Stacked = SoftwareFX.ChartFX.Lite.Stacked.No;
ou
chart1.Stacked = SoftwareFX.ChartFX.Lite.Stacked.Normal;
- Légendes
chart1.Legend[0] = "legende desirée";
- etc.