Bonjour,

Je ne pense pas être dans le bon forum, mais n'ayant pas trouvé de forum sur la programmation d'interface graphique pour powershell, j'ai positionné ma discussion dans ce qui me paraissait le plus proche.

Problème :
Mon soucis est de ne pas réussir (après bien des essais) à créer un graphique de type "camembert" (Pie chart) sous powershell.

Voici mon code :
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
 
#****************************************************************************************************************
#***	Chargement des bibliothèques Winforms
#***    Chargement de la bibliothèque pour avoir accès aux outils graphiques (partie de .NET)
#****************************************************************************************************************
[void][Reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
[void][Reflection.assembly]::LoadWithPartialName("System.Drawings")
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
 
# Forme principale
$Graphique = New-Object System.Windows.Forms.Form
$Graphique.Text = "Test"
$Graphique.SizeGripStyle = "Hide"
$Graphique.Opacity = 1.0							#1.0 = 100 %; 0.0 = invisible
$Graphique.Location.X = 10
$Graphique.Location.Y = 22
$Graphique.Width = 700
$Graphique.Height = 700				
$Graphique.Icon = $C_MailOpenClose
$Graphique.Maximizebox = $False						# Bouton pour mettre en plein écran
$Graphique.Minimizebox = $True						# Bouton pour mettre dans la barre des tâches
 
# Objet Graphique (G_)
$G_Graphique = New-object System.Windows.Forms.DataVisualization.Charting.Chart 
$Graphique.controls.add($G_Graphique)											#
$Graphique.Add_Shown({$Graphique.Activate()}) 									# Afficher le graphique dans la forme
$G_Graphique.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right -bor [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left 
 
# Objet Zone Graphique (ZG_)
$ZG_GraphArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea 
 
# Paramètres du graphique
$G_Graphique.ChartAreas.Add($ZG_GraphArea)										# Ajout du graphique dans la zone graphique
[void]$G_Graphique.Titles.Add("Top 5 European Cities by Population")
$G_Graphique.BackColor = [System.Drawing.Color]::Transparent					# Enleve la zone blanche derrière le graphique
$G_Graphique.Series["Data"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Pie
 
# Ajouter des données au graphique
$V_Data = @{Test=7556900; Berlin=3429900; Madrid=3213271; Rome=2726539; Paris=2188500} 
[void]$G_Graphique.Series.Add("Data") 
$G_Graphique.Series["Data"].Points.DataBindXY($V_Data.Keys, $V_Data.Values)
 
#****************************************************************************************************************
#***	Affichage 
#****************************************************************************************************************
$Graphique.ShowDialog()
Site suivi : http://blogs.technet.com/b/richard_m...8/3231887.aspx

J'ai beau modifier le paramètre "$G_Graphique.Series["Data"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]:: Pie" il ne fait que m'afficher un graphique en forme d'histogramme (cf le site que j'ai suivi pour la création du graphique, j'obtiens le graph en histogramme basique (même pas en 3D alors que j'avais ajouté les paramètres pour essayer et ça à pas marché...)).

Quelqu'un aurait-il une idée ?

Bien cordialement,