OxyPlot.Series.PieSeries.ps1

Set-StrictMode -Version 3

<#
.SYNOPSIS
 
Represents a series for pie/circle/doughnut charts.
 
The arc length/central angle/area of each slice is proportional to the quantity it represents.
See Pie charts (http://en.wikipedia.org/wiki/Pie_chart).
 
.PARAMETER Parent
 
Gets the parent model of the element.
 
.PARAMETER ItemsSource
Sets the items source. The default is null.
 
.PARAMETER Background
Sets the background color of the series. The default is OxyColors.Undefined.
 
This property defines the background color in the area defined by the x and y axes used by this series.
 
.PARAMETER IsVisible
Sets a value indicating whether this series is visible. The default is true.
 
.PARAMETER Title
Sets the title of the series. The default is null.
 
.PARAMETER RenderInLegend
Sets a value indicating whether the series should be rendered in the legend. The default is true.
 
.PARAMETER TrackerFormatString
Sets a format string used for the tracker. The default depends on the series.
 
The arguments for the format string may be different for each type of series. See the documentation.
 
.PARAMETER TrackerKey
Sets the key for the tracker to use on this series. The default is null.
 
This key may be used by the plot view to show a custom tracker for the series.
 
.PARAMETER AngleIncrement
Sets the angle increment.
 
.PARAMETER AngleSpan
Sets the angle span.
 
.PARAMETER AreInsideLabelsAngled
Sets a value indicating whether inside labels are angled.
 
.PARAMETER ColorField
Sets the name of the property containing the color.
 
.PARAMETER Diameter
Sets the diameter.
 
.PARAMETER ExplodedDistance
Sets the exploded distance.
 
.PARAMETER InnerDiameter
Sets the inner diameter.
 
.PARAMETER InsideLabelColor
Sets the color of the inside labels.
 
If the value is OxyColors.Automatic, the OxyPlot.PlotElement.TextColor will be used.
 
.PARAMETER InsideLabelFormat
Sets the inside label format.
 
The formatting arguments are: value {0}, label {1} and percentage {2}.
 
.PARAMETER InsideLabelPosition
Sets the inside label position.
 
.PARAMETER IsExplodedField
Sets the is exploded field.
 
.PARAMETER LabelField
Sets the label field.
 
.PARAMETER LegendFormat
Sets the legend format.
 
.PARAMETER OutsideLabelFormat
Sets the outside label format.
 
.PARAMETER Slices
Sets the slices.
 
.PARAMETER StartAngle
Sets the start angle.
 
.PARAMETER Stroke
Sets the stroke color.
 
.PARAMETER StrokeThickness
Sets the stroke thickness.
 
.PARAMETER TickDistance
Sets the distance from the edge of the pie slice to the tick line.
 
.PARAMETER TickHorizontalLength
Sets the length of the horizontal part of the tick.
 
.PARAMETER TickLabelDistance
Sets the distance from the tick line to the outside label.
 
.PARAMETER TickRadialLength
Sets the length of the radial part of the tick line.
 
.PARAMETER ValueField
Sets the name of the property containing the value.
 
.PARAMETER Font
Sets the font. The default is null (use OxyPlot.PlotModel.DefaultFont.
 
If the value is null, the DefaultFont of the parent PlotModel will be used.
 
.PARAMETER FontSize
Sets the size of the font. The default is double.NaN (use OxyPlot.PlotModel.DefaultFontSize).
 
If the value is NaN, the DefaultFontSize of the parent PlotModel will be used.
 
.PARAMETER FontWeight
Sets the font weight. The default is FontWeights.Normal.
 
.PARAMETER PlotModel
 
Gets the parent OxyPlot.PlotElement.PlotModel.
 
.PARAMETER Tag
Sets an arbitrary object value that can be used to store custom information about this plot element. The default is null.
 
This property is analogous to Tag properties in other Microsoft programming models. Tag is intended to provide a pre-existing property location where you can store some basic custom information about any PlotElement without requiring you to subclass an element.
 
.PARAMETER TextColor
Sets the color of the text. The default is OxyColors.Automatic (use OxyPlot.PlotModel.TextColor).
 
If the value is OxyColors.Automatic, the TextColor of the parent PlotModel will be used.
 
.PARAMETER ToolTip
Sets the tool tip. The default is null.
 
.PARAMETER ActualFont
 
Gets the actual font.
 
.PARAMETER ActualFontSize
 
Gets the actual size of the font.
 
.PARAMETER ActualFontWeight
 
Gets the actual font weight.
 
.PARAMETER ActualTextColor
 
Gets the actual color of the text.
 
.PARAMETER ActualCulture
 
Gets the actual culture.
 
The culture is defined in the parent PlotModel.
 
.PARAMETER Selectable
Sets a value indicating whether this element can be selected. The default is true.
 
.PARAMETER SelectionMode
Sets the selection mode of items in this element. The default is SelectionMode.All.
 
This is only used by the select/unselect functionality, not by the rendering.
 
.PARAMETER ActualSelectedColor
 
Gets the actual selection color.
 
.LINK
http://en.wikipedia.org/wiki/Pie_chart
 
.PARAMETER InputObject
Sets the source of the data set.
 
.PARAMETER Label
Sets the column Label of the data set.
 
.PARAMETER InputObject
Sets the source of the data set.
 
.PARAMETER Value
Sets the column Value of the data set.
 
.PARAMETER InputObject
Sets the source of the data set.
 
.PARAMETER Fill
Sets the column Fill of the data set.
 
.PARAMETER InputObject
Sets the source of the data set.
 
.PARAMETER IsExploded
Sets the column IsExploded of the data set.
 
.PARAMETER Group
Specifies groups to which each element of the data set belongs.
 
If this parameter is set, the data set will be grouped by these values, and multiple series will be produced for each group.
 
.PARAMETER LabelName
Specifies a property name of the input objects to be assigned to the column Label of the data set.
 
.PARAMETER ValueName
Specifies a property name of the input objects to be assigned to the column Value of the data set.
 
.PARAMETER FillName
Specifies a property name of the input objects to be assigned to the column Fill of the data set.
 
.PARAMETER IsExplodedName
Specifies a property name of the input objects to be assigned to the column IsExploded of the data set.
 
.PARAMETER GroupName
Specifies a property name of the input objects to be treated as groups.
 
If this parameter is set, the data set will be grouped by the values of this property, and multiple series will be produced for each group.
 
.PARAMETER GroupingKeys
Specifies effective groups and these order.
 
This option is useful when you will select groups, or specify the order of the groups shown in the legend.
 
.PARAMETER Options
Sets properties of the object.
 
.PARAMETER Style
Sets a style of the object.
 
.PARAMETER AddTo
Specifies a plot model to which the object will be added.
 
.INPUTS
You can send any object to the cmdlet as the source of the data set.
#>

function New-OxyPieSeries {
  [cmdletbinding()]
  [OutputType([OxyPlot.Series.PieSeries[]], [void])]
  param(
    [Parameter(ValueFromPipeline=$true)]
    [object]$InputObject,

    [string[]]$Label = @(),
    [double[]]$Value = @(),
    [string[]]$Fill = @(),
    [object[]]$IsExploded = @(),
    [string[]]$Group = @(),

    [string]$LabelName,
    [string]$ValueName,
    [string]$FillName,
    [string]$IsExplodedName,
    [string]$GroupName,
    [string[]]$GroupingKeys = @(),

    [double]$AngleIncrement,
    [double]$AngleSpan,
    [bool]$AreInsideLabelsAngled,
    [string]$ColorField,
    [double]$Diameter,
    [double]$ExplodedDistance,
    [double]$InnerDiameter,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$InsideLabelColor,
    [string]$InsideLabelFormat,
    [double]$InsideLabelPosition,
    [string]$IsExplodedField,
    [string]$LabelField,
    [string]$LegendFormat,
    [string]$OutsideLabelFormat,
    [System.Collections.Generic.IList[OxyPlot.Series.PieSlice]]$Slices,
    [double]$StartAngle,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$Stroke,
    [double]$StrokeThickness,
    [double]$TickDistance,
    [double]$TickHorizontalLength,
    [double]$TickLabelDistance,
    [double]$TickRadialLength,
    [string]$ValueField,
    [System.Collections.IEnumerable]$ItemsSource,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$Background,
    [bool]$IsVisible,
    [string]$Title,
    [bool]$RenderInLegend,
    [string]$TrackerFormatString,
    [string]$TrackerKey,
    [string]$Font,
    [double]$FontSize,
    [double]$FontWeight,
    [System.Object]$Tag,
    [ValidatePattern('AliceBlue|AntiqueWhite|Aqua|Aquamarine|Automatic|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenrod|DarkGray|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DodgerBlue|Firebrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|Goldenrod|Gray|Green|GreenYellow|Honeydew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenrodYellow|LightGray|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquamarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenrod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Transparent|Turquoise|Undefined|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen|(#?[0-9a-f]{1,8})')][string]$TextColor,
    [string]$ToolTip,
    [bool]$Selectable,
    [OxyPlot.SelectionMode]$SelectionMode,
    [OxyPlot.Model]$Parent,

    [hashtable]$Options = @{},

    [string]$Style = "default",
    [OxyPlot.PlotModel]$AddTo
  )

begin {

  if (!(Test-OxyStyleName $Style)) {
    Write-Error "Unknown style: '$Style'"
    return
  }

  $info = [PSCustomObject]@{
    XAxisTitle = $null
    YAxisTitle = $null
    XDataType = $null
    YDataType = $null
    GroupName = $GroupName
    CategoryNames = @()
    CategoryTitle = $null
  }



  $LabelData = New-Object Collections.Generic.List[string]
  $ValueData = New-Object Collections.Generic.List[double]
  $FillData = New-Object Collections.Generic.List[string]
  $IsExplodedData = New-Object Collections.Generic.List[object]
  $GroupData = New-Object Collections.Generic.List[string]

  Set-StrictMode -Off
}

process {
  if ($InputObject -ne $null) {
    if ($PSBoundParameters.ContainsKey("LabelName")) { $LabelData.Add($InputObject.$LabelName) }
    if ($PSBoundParameters.ContainsKey("ValueName")) { $ValueData.Add($InputObject.$ValueName) }
    if ($PSBoundParameters.ContainsKey("FillName")) { $FillData.Add($InputObject.$FillName) }
    if ($PSBoundParameters.ContainsKey("IsExplodedName")) { $IsExplodedData.Add($InputObject.$IsExplodedName) }
    if ($PSBoundParameters.ContainsKey("GroupName")) { $GroupData.Add($InputObject.$GroupName) }
  }
}

end {
  if ($LabelData.Count -gt 0 -and $Label.Count -gt 0) { Write-Error "Data set of 'Label' is given in two ways"; return }
  if ($ValueData.Count -gt 0 -and $Value.Count -gt 0) { Write-Error "Data set of 'Value' is given in two ways"; return }
  if ($FillData.Count -gt 0 -and $Fill.Count -gt 0) { Write-Error "Data set of 'Fill' is given in two ways"; return }
  if ($IsExplodedData.Count -gt 0 -and $IsExploded.Count -gt 0) { Write-Error "Data set of 'IsExploded' is given in two ways"; return }
  if ($GroupData.Count -gt 0 -and $Group.Count -gt 0) { Write-Error "Data set of 'Group' is given in two ways"; return }

  $LabelData.AddRange($Label)
  $ValueData.AddRange($Value)
  $FillData.AddRange($Fill)
  $IsExplodedData.AddRange($IsExploded)
  $GroupData.AddRange($Group)

  if ($GroupData.Count -gt 0) {
    $groups = @{}
    foreach ($e in $GroupData) {
      $groups[$e] = 1
    }
    if ($GroupKeys.Count -eq 0) {
      $groupKeys = $groups.Keys | Sort
    }
    $grouping = $true
  }
  else {
    $groupKeys = @("dummy")
    $grouping = $false
  }

  $dataCount = $LabelData.Count
  foreach ($group in $groupKeys) {

    $series = New-Object OxyPlot.Series.PieSeries

    if ($grouping) {
      $series.Title = $group
    }

    foreach ($key in $Options.Keys) {
      $series.$key = $Options[$key]
    }
    if ($PSBoundParameters.ContainsKey('AngleIncrement')) { $series.AngleIncrement = $AngleIncrement }
    if ($PSBoundParameters.ContainsKey('AngleSpan')) { $series.AngleSpan = $AngleSpan }
    if ($PSBoundParameters.ContainsKey('AreInsideLabelsAngled')) { $series.AreInsideLabelsAngled = $AreInsideLabelsAngled }
    if ($PSBoundParameters.ContainsKey('ColorField')) { $series.ColorField = $ColorField }
    if ($PSBoundParameters.ContainsKey('Diameter')) { $series.Diameter = $Diameter }
    if ($PSBoundParameters.ContainsKey('ExplodedDistance')) { $series.ExplodedDistance = $ExplodedDistance }
    if ($PSBoundParameters.ContainsKey('InnerDiameter')) { $series.InnerDiameter = $InnerDiameter }
    if ($PSBoundParameters.ContainsKey('InsideLabelColor')) { $series.InsideLabelColor = New-OxyColor $InsideLabelColor }
    if ($PSBoundParameters.ContainsKey('InsideLabelFormat')) { $series.InsideLabelFormat = $InsideLabelFormat }
    if ($PSBoundParameters.ContainsKey('InsideLabelPosition')) { $series.InsideLabelPosition = $InsideLabelPosition }
    if ($PSBoundParameters.ContainsKey('IsExplodedField')) { $series.IsExplodedField = $IsExplodedField }
    if ($PSBoundParameters.ContainsKey('LabelField')) { $series.LabelField = $LabelField }
    if ($PSBoundParameters.ContainsKey('LegendFormat')) { $series.LegendFormat = $LegendFormat }
    if ($PSBoundParameters.ContainsKey('OutsideLabelFormat')) { $series.OutsideLabelFormat = $OutsideLabelFormat }
    if ($PSBoundParameters.ContainsKey('Slices')) { $series.Slices = $Slices }
    if ($PSBoundParameters.ContainsKey('StartAngle')) { $series.StartAngle = $StartAngle }
    if ($PSBoundParameters.ContainsKey('Stroke')) { $series.Stroke = New-OxyColor $Stroke }
    if ($PSBoundParameters.ContainsKey('StrokeThickness')) { $series.StrokeThickness = $StrokeThickness }
    if ($PSBoundParameters.ContainsKey('TickDistance')) { $series.TickDistance = $TickDistance }
    if ($PSBoundParameters.ContainsKey('TickHorizontalLength')) { $series.TickHorizontalLength = $TickHorizontalLength }
    if ($PSBoundParameters.ContainsKey('TickLabelDistance')) { $series.TickLabelDistance = $TickLabelDistance }
    if ($PSBoundParameters.ContainsKey('TickRadialLength')) { $series.TickRadialLength = $TickRadialLength }
    if ($PSBoundParameters.ContainsKey('ValueField')) { $series.ValueField = $ValueField }
    if ($PSBoundParameters.ContainsKey('ItemsSource')) { $series.ItemsSource = $ItemsSource }
    if ($PSBoundParameters.ContainsKey('Background')) { $series.Background = New-OxyColor $Background }
    if ($PSBoundParameters.ContainsKey('IsVisible')) { $series.IsVisible = $IsVisible }
    if ($PSBoundParameters.ContainsKey('Title')) { $series.Title = $Title }
    if ($PSBoundParameters.ContainsKey('RenderInLegend')) { $series.RenderInLegend = $RenderInLegend }
    if ($PSBoundParameters.ContainsKey('TrackerFormatString')) { $series.TrackerFormatString = $TrackerFormatString }
    if ($PSBoundParameters.ContainsKey('TrackerKey')) { $series.TrackerKey = $TrackerKey }
    if ($PSBoundParameters.ContainsKey('Font')) { $series.Font = $Font }
    if ($PSBoundParameters.ContainsKey('FontSize')) { $series.FontSize = $FontSize }
    if ($PSBoundParameters.ContainsKey('FontWeight')) { $series.FontWeight = $FontWeight }
    if ($PSBoundParameters.ContainsKey('Tag')) { $series.Tag = $Tag }
    if ($PSBoundParameters.ContainsKey('TextColor')) { $series.TextColor = New-OxyColor $TextColor }
    if ($PSBoundParameters.ContainsKey('ToolTip')) { $series.ToolTip = $ToolTip }
    if ($PSBoundParameters.ContainsKey('Selectable')) { $series.Selectable = $Selectable }
    if ($PSBoundParameters.ContainsKey('SelectionMode')) { $series.SelectionMode = $SelectionMode }
    if ($PSBoundParameters.ContainsKey('Parent')) { $series.Parent = $Parent }

    for ($i = 0; $i -lt $dataCount; ++$i) {
      if ($grouping -and $GroupData[$i] -ne $group) {
        continue
      }
      if ($i -lt $LabelData.Count) { $LabelElement = $LabelData[$i] } else { $LabelElement = $null }
      if ($i -lt $ValueData.Count) { $ValueElement = $ValueData[$i] } else { $ValueElement = $null }
      if ($i -lt $FillData.Count) { $FillElement = $FillData[$i] } else { $FillElement = $null }
      if ($i -lt $IsExplodedData.Count) { $IsExplodedElement = $IsExplodedData[$i] } else { $IsExplodedElement = $null }
      Add-OxyPieSeriesPoint $series $LabelElement $ValueElement $FillElement $IsExplodedElement
    }


    $series = $series | Add-Member -PassThru NoteProperty _Info $info

    Apply-OxyStyle $series $Style $MyInvocation

    if ($AddTo -ne $null) {
      Add-OxyObjectToPlotModel $series $AddTo -NoRefresh
    }
    else {
      $series
    }
  }

  if ($AddTo -ne $null) {
    $AddTo.InvalidatePlot($true)
  }
}
}