Page 1 of 1

Stacked Column Chart

Posted: Tue Oct 27, 2015 8:47 am
by boyddt_co
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

Re: Stacked Column Chart

Posted: Tue Oct 27, 2015 9:54 am
by jvierra
There doesn't appear to ba any relationship between your data and the chart.

Re: Stacked Column Chart

Posted: Tue Oct 27, 2015 9:56 am
by jvierra
Here is some background on the chart control.

https://www.sapien.com/blog/2011/05/05/ ... owershell/

Re: Stacked Column Chart

Posted: Tue Oct 27, 2015 12:29 pm
by boyddt_co
jvierra wrote:There doesn't appear to ba any relationship between your data and the chart.
and therein lies the problem...

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

Posted: Tue Oct 27, 2015 12:54 pm
by jvierra
Just set the chart to stacked bar.

Here are all f the possible type codes.
https://msdn.microsoft.com/en-us/libra ... .110).aspx

Re: Stacked Column Chart

Posted: Wed Oct 28, 2015 7:46 am
by dan.potter
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.
  1. $Chart2.Titles["Title1"].Text = "Used $usedlic of $purchasedlic allocated licenses."
  2.        
  3.         $Chart2.Series["Series1"].Points.Clear()
  4.         $Chart2.Series["Series2"].Points.Clear()
  5.        
  6.         $Chart2.Series["Series1"].Points.AddY($usedlic)
  7.         $Chart2.Series["Series2"].Points.AddY($remaininglic)
  8.        
  9.         $maxValue = $Chart2.Series["Series1"].Points.FindMaxByValue()
  10.         $maxValue.Color = [System.Drawing.Color]::DodgerBlue
  11.         $minValue = $Chart2.Series["Series2"].Points.FindMinByValue()
  12.         $minValue.Color = [System.Drawing.Color]::FloralWhite

Re: Stacked Column Chart

Posted: Wed Oct 28, 2015 8:05 am
by dan.potter
ok then.

Re: Stacked Column Chart

Posted: Wed Oct 28, 2015 8:44 am
by jvierra
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.

Re: Stacked Column Chart

Posted: Thu Oct 29, 2015 6:53 am
by boyddt_co
Dan, thank you for the help, I'll play with it tomorrow and see how I do.