Bonjour à tous,
j'utilise zedGraph dans mon application pour faire des graphiques en camembert tous se passe bien sauf que toutes les portions ont la même couleur. J rappel la source de données de mes graphes est un dataset:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
void RemplirDSGraphe(string SortieTop)
        {
            ///// On prépare les éléments du graphe            
 
            GraphPane myPane = zGControl.GraphPane;
            myPane.GraphObjList.Clear();
            zGInitialise(myPane);            
            try
            {
                string myReq = Reqete(sortieTop, De.Text, Au.Text, cboSecteur.Text,
                    cboAnnonceur.Text, cboMarque.Text, cboSupport.Text, "TV");
                double myTotal = 0d;
                myTotal = double.Parse(totalTop.Text);
                myTopAdap = new OdbcDataAdapter(mySQL, myGeneralClass.myCurcon);
                myTopAdap.Fill(myTopDS, "Top" + SortieTop);
                System.Data.DataTable myTopTable;
                myTopTable = myTopDS.Tables["Top" + SortieTop];
                int n=myTopTable.Rows.Count;
                int m = myTopTable.Columns.Count;
                ZedGraph.PieItem segment;
                //int n = myTopDS.Tables["Top"].Rows.Count;                
                for (int i=0; i <= n-1 ; i++)
                {
                    for (int j = 1; j < m; j++)
                    {                        
                        Random myRand = new Random();
                        //string val = myTopTable.Rows[i][j].ToString();
                        double _val = double.Parse(myTopTable.Rows[i][j].ToString());
                        Color Color1 = Color.FromArgb(myRand.Next(150, 200), myRand.Next(200, 250), myRand.Next(100, 150));
                        Color Color2 = Color.FromArgb(myRand.Next(0, 50), myRand.Next(50, 100), myRand.Next(100, 150));
                        string Libelle = myTopTable.Rows[i][0].ToString();
                        double prCentage = (_val / myTotal)*100;
                        segment = myPane.AddPieSlice(_val, Color1, Color2, 45f, 0, Libelle+" "+prCentage.ToString()+"%");                        
                    }
                }                    
                // Somme des valeurs des tranche                                                               
                CurveList curves = myPane.CurveList;
                //totalTop.Text = myTotal.ToString();
                TextObj text = new TextObj("Total Investissement FCFA  \n" + totalTop.Text + " FCFA",
                               0.18F, 0.40F, CoordType.PaneFraction);
                text.Location.AlignH = AlignH.Center;
                text.Location.AlignV = AlignV.Bottom;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill = new Fill(Color.White, Color.FromArgb(255, 100, 100), 45F);
                text.FontSpec.StringAlignment = StringAlignment.Center;
                myPane.GraphObjList.Add(text);
 
                // Create a drop shadow for the total value text item
                TextObj text2 = new TextObj(text);
                text2.FontSpec.Fill = new Fill(Color.Black);
                text2.Location.X += 0.008f;
                text2.Location.Y += 0.01f;
                myPane.GraphObjList.Add(text2);
                // Calculate the Axis Scale Ranges
                zGControl.AxisChange();               
            }
Les lignes me permettant d'ajouter les portions sont les suivantes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
double _val = double.Parse(myTopTable.Rows[i][j].ToString());
                        Color Color1 = Color.FromArgb(myRand.Next(150, 200), myRand.Next(200, 250), myRand.Next(100, 150));
                        Color Color2 = Color.FromArgb(myRand.Next(0, 50), myRand.Next(50, 100), myRand.Next(100, 150));
                        string Libelle = myTopTable.Rows[i][0].ToString();
                        double prCentage = (_val / myTotal)*100;
                        segment = myPane.AddPieSlice(_val, Color1, Color2, 45f, 0, Libelle+" "+prCentage.ToString()+"%");
Or j'ai toujours les mêmes couleurs pour les différentes portions ajoutées. Quelqu'un a t-il une idées?