Added ValueFromPipeline to the data parameter

This commit is contained in:
dfinke
2015-12-26 16:25:50 -05:00
parent 0cee3a5576
commit d883000327
2 changed files with 44 additions and 16 deletions

View File

@@ -1,11 +1,11 @@
function DoChart {
param(
$targetData,
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType,
[Switch]$NoLegend,
[Switch]$ShowCategory,
[Switch]$ShowPercent
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType,
[Switch]$NoLegend,
[Switch]$ShowCategory,
[Switch]$ShowPercent
)
if($targetData[0] -is [System.ValueType]) {
@@ -25,11 +25,11 @@ function DoChart {
$xlFile = (New-TemporaryFile).fullname -replace "tmp","xlsx"
$targetData | Export-Excel $xlFile -ExcelChartDefinition $chart -Show -AutoSize
}
}
function BarChart {
param(
[Parameter(ValueFromPipeline=$true)]
$targetData,
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="BarStacked",
@@ -38,13 +38,18 @@ function BarChart {
[Switch]$ShowPercent
)
DoChart $targetData $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
Begin { $data = @() }
Process { $data += $targetData}
}
End {
DoChart $data $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
}
}
function PieChart {
param(
[Parameter(ValueFromPipeline=$true)]
$targetData,
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="PieExploded3D",
@@ -53,12 +58,18 @@ function PieChart {
[Switch]$ShowPercent
)
DoChart $targetData $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
Begin { $data = @() }
Process { $data += $targetData}
End {
DoChart $data $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
}
}
function LineChart {
param(
[Parameter(ValueFromPipeline=$true)]
$targetData,
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="Line",
@@ -67,12 +78,18 @@ function LineChart {
[Switch]$ShowPercent
)
DoChart $targetData $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
Begin { $data = @() }
Process { $data += $targetData}
End {
DoChart $data $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
}
}
function ColumnChart {
param(
[Parameter(ValueFromPipeline=$true)]
$targetData,
$title,
[OfficeOpenXml.Drawing.Chart.eChartType]$ChartType="ColumnStacked",
@@ -81,6 +98,11 @@ function ColumnChart {
[Switch]$ShowPercent
)
DoChart $targetData $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
Begin { $data = @() }
Process { $data += $targetData}
End {
DoChart $data $title -ChartType $ChartType `
-NoLegend:$NoLegend -ShowCategory:$ShowCategory -ShowPercent:$ShowPercent
}
}

View File

@@ -25,7 +25,13 @@ Known Issues
What's new
-
#### 12/26/2015
* Added `NoLegend`, `Show-Category`, `ShowPercent` for all charts including Pivot Charts
* Updated PieChart, BarChart, ColumnChart and Line chart to work with the pipeline and added `NoLegend`, `Show-Category`, `ShowPercent`
#### 12/17/2015
These new features open the door for really sophisticated work sheet creation.
Stay tuned for a [blog post](http://www.dougfinke.com/blog/) and examples.