Question Utilisation des MSChart : un nom par colonne

Plus d'informations
il y a 14 ans 10 mois #9527 par Burgun
Bonjour,

J'utilise PS depuis quelques temps pour des opérations d'administration de base. Je ne suis pas très calé sur le sujet mais grace à ce forum et à de nombreux site du web, je me débrouille.

Mais je viens de débuter avec l'usage des interface graphiques et nottament la génération de graphique et je rame....

Mon besoin est le suivant: je récupérere à intervalle régulier le taux d'occupation en espace libre de différents partage sur un nas. J'aimerais proposé un résumé dans un graphique en barre avec pour chaque partage le taux d'espace occupé. Voici la partie de mon code pour ceci (inspiré de la blogs.technet.com/b/richard_macdonald/ar...9/04/28/3231887.aspx)

[code:1]
# Chargement des classes .net nécessaire
[void][Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\"«»)
[void][Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms.DataVisualization\"«»)

#Chemin
$Path=\"D:\temp\MSchart\Graph\"
Set-Location $Path

###Diagramme en baton###
# Création de l'objet Chart
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$Chart.Width = 1000
$Chart.Height = 400
$Chart.Left = 40
$Chart.Top = 30

# Création du support qui va acceuillir le Grpah
$ChartArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
$Chart.ChartAreas.Add($ChartArea)


# Ajout des données au graphe
$Service=Get-Content Service.txt
$NomPartage=@(foreach($Partage in $Service){$Partage.split(\";\"«»)[0]})
$Conso=@(foreach($Partage in $Service){$Partage.split(\";\"«»)[3]})

[void]$Chart.Series.Add(\"Data\"«»)
$Chart.Series[\"Data\"].Points.DataBindXY($NomPartage, $Conso)

# Définition du titre des graphes
[void]$Chart.Titles.Add(\"Consommation des partages pour le FS Service\"«»)
$ChartArea.AxisX.Title = \"Partage\"
$ChartArea.AxisY.Title = \"% d'occuption\"

# Find point with max/min values and change their colour
$maxValuePoint = $Chart.Series[\"Data\"].Points.FindMaxByValue()
$maxValuePoint.Color = [System.Drawing.Color]::Red
$minValuePoint = $Chart.Series[\"Data\"].Points.FindMinByValue()
$minValuePoint.Color = [System.Drawing.Color]::Green

# make bars into 3d cylinders
$Chart.Series[\"Data\"][\"DrawingStyle\"] = \"Cylinder\"

#Modification du classement
#$Chart.Series[\"Data\"].Sort([System.Windows.Forms.DataVisualization.Charting.PointSortOrder]::«»Descending, \"Y\"«»)

# display the chart on a form
$Chart.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right -bor
[System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left
$Form = New-Object Windows.Forms.Form
$Form.Text = \"PowerShell Chart\"
$Form.Width = 1100
$Form.Height = 600
$Form.controls.add($Chart)
$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()


$Chart.SaveImage(\"D:\temp\MSchart\Baton.png\", \"PNG\"«»)

[/code:1]

J'obtiens le résultat en pièce jointe

Le problème c'est que l'axe X n'est pas exploitable. J'aimerais que s'affiche sous chaque barre le nom du partage. Hors j'ai l'impression que ce n'est pas du tout le cas. Je n'ai que quelques partages dont le nom s'affiche. Auriez vous une piste pour moi ? <br><br>Message édité par: vburg, à: 2/05/11 12:10
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 14 ans 10 mois #9531 par Burgun
Après plus de test, il s'avère que le problème intervient une fois une liste incluant 9 partages.

Si je liste 8 partage, l'axe des X s'affiche correctement. Si j'en rajoute un 9 eme,le nom ne s'affiche plus correctement en dessous de chaque barre.

J'ai tenté de raccourcir le nom des partages, agrandir le graphique....rien ne fonctionne.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 14 ans 10 mois #9532 par Burgun
j'ai trouvé :)

A partir du site suivant
stackoverflow.com/questions/2435540/ms-c...label-if-there-are-m


J'en ai déduis cette ligne
$ChartArea.AxisX.Interval = 1;

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.063 secondes
Propulsé par Kunena