0
使用.Net圖表控件創建一些圖表,圖形。此刻,我能夠拯救那些圖表,圖表分別對每個圖像文件,如下所示:使用.Net圖表控件添加多個圖像
$mailHash = @{"Email Set"=$emailPer;"No Email"=$noEmailPer}
$outFilePic= "C:\My Documents\Documents"
Function drawPie ($hash){
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Windows.Forms.DataVisualization
$Chart = New-object System.Windows.Forms.DataVisualization.Charting.Chart
$ChartArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
$Series = New-Object -TypeName System.Windows.Forms.DataVisualization.Charting.Series
$ChartTypes = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]
$Series.ChartType = $ChartTypes::Pie
$Chart.Series.Add($Series)
$Chart.ChartAreas.Add($ChartArea)
$Chart.Series['Series1'].Points.DataBindXY($hash.keys, $hash.values)
$Chart.Series[‘Series1’][‘PieLabelStyle’] = ‘Disabled’
$Legend = New-Object System.Windows.Forms.DataVisualization.Charting.Legend
$Legend.IsEquallySpacedItems = $True
$Legend.BorderColor = 'Black'
$Chart.Legends.Add($Legend)
$chart.Series["Series1"].LegendText = "#VALX (#VALY%)"
$Chart.Width = 700
$Chart.Height = 400
$Chart.Left = 10
$Chart.Top = 10
$Chart.BackColor = [System.Drawing.Color]::White
$Chart.BorderColor = 'Black'
$Chart.BorderDashStyle = 'Solid'
$ChartTitle = New-Object System.Windows.Forms.DataVisualization.Charting.Title
$ChartTitle.Text = 'Email '
$Font = New-Object System.Drawing.Font @('Microsoft Sans Serif','12', [System.Drawing.FontStyle]::Bold)
$ChartTitle.Font =$Font
$Chart.Titles.Add($ChartTitle)
$Chart.SaveImage($outFilePic, 'jpeg')
}
以上是動態函數創建對餅圖。因此,也會創建許多不同的圖表。如何將這些保存在一個圖像中?
韓國社交協會這麼多的隊友!對此,我真的非常感激。您好:D – Ender
嗯,當我嘗試將餅圖和條形圖結合在一起時,我遇到了問題。我遇到了一個錯誤「_圖表區域 包含不兼容的圖表類型,例如,條形圖和柱形圖表不能存在於同一個圖表區域中。有沒有可能解決? – Ender
@Ender我已經更新了Pie和Bar chart中的代碼,你可以檢查一下嗎? –