I am looking to create a stacked column chart and I'm struggling mentally. my data set is below.and I'm trying to figure out how to set it up in an array that the chart can use.
This is a snippet of the code. If you need more to see what I'm doing I can add to it.
# add data to chart
$Cities = @{London=7556900; Berlin=3429900; Madrid=3213271; Rome=2726539; Paris=2188500}
[void]$Chart.Series.Add("Data")
$Chart.Series["Data"].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::stackedcolumn
$Chart.Series["Data"].Points.DataBindXY($Cities.Keys, $Cities.Values)
Operator OpCount dt
George 5 10/20/2015 12:00:00 AM
George 6 10/21/2015 12:00:00 AM
George 2 10/22/2015 12:00:00 AM
George 3 10/23/2015 12:00:00 AM
George 5 10/26/2015 12:00:00 AM
Sam 5 10/20/2015 12:00:00 AM
Sam 3 10/21/2015 12:00:00 AM
Sam 6 10/22/2015 12:00:00 AM
Sam 4 10/23/2015 12:00:00 AM
Sam 3 10/26/2015 12:00:00 AM
Sarah 6 10/20/2015 12:00:00 AM
Sarah 8 10/21/2015 12:00:00 AM
Sarah 6 10/22/2015 12:00:00 AM
Sarah 5 10/23/2015 12:00:00 AM
Sarah 7 10/26/2015 12:00:00 AM
Stacked Column Chart
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Stacked Column Chart
Here is some background on the chart control.
https://www.sapien.com/blog/2011/05/05/ ... owershell/
https://www.sapien.com/blog/2011/05/05/ ... owershell/
Re: Stacked Column Chart
and therein lies the problem...jvierra wrote:There doesn't appear to ba any relationship between your data and the chart.
I can't find anything that explains how to construct the code for a stacked column chart. I've looked through MSN and maybe it is because I'm slow but didn't see much there either and the link that you sent me only talks about bar & pie charts.
Any help would be appreciated.
David
Re: Stacked Column Chart
Just set the chart to stacked bar.
Here are all f the possible type codes.
https://msdn.microsoft.com/en-us/libra ... .110).aspx
Here are all f the possible type codes.
https://msdn.microsoft.com/en-us/libra ... .110).aspx
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Stacked Column Chart
I hear you David, charts for me had my head spinning.
For stacked add two series. Start with static numbers first. Here is something I did for MS office subcriptions.
For stacked add two series. Start with static numbers first. Here is something I did for MS office subcriptions.
- $Chart2.Titles["Title1"].Text = "Used $usedlic of $purchasedlic allocated licenses."
- $Chart2.Series["Series1"].Points.Clear()
- $Chart2.Series["Series2"].Points.Clear()
- $Chart2.Series["Series1"].Points.AddY($usedlic)
- $Chart2.Series["Series2"].Points.AddY($remaininglic)
- $maxValue = $Chart2.Series["Series1"].Points.FindMaxByValue()
- $maxValue.Color = [System.Drawing.Color]::DodgerBlue
- $minValue = $Chart2.Series["Series2"].Points.FindMinByValue()
- $minValue.Color = [System.Drawing.Color]::FloralWhite
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Stacked Column Chart
ok then.
- Attachments
-
- chart.psf
- (27.25 KiB) Downloaded 253 times
-
- chart.psf
- (27.25 KiB) Downloaded 205 times
-
- chart.psf
- (27.25 KiB) Downloaded 199 times
Re: Stacked Column Chart
The Load-Chart function has a chartstyle parameter. Just set it to StackedBar. THat is all that is required. Everything else will be done automatically.
If you want to manually build charts from scratch then the same ius true. Set ChartType on a series to StackedBar.
If you want to manually build charts from scratch then the same ius true. Set ChartType on a series to StackedBar.