From 665b88682a542bc250ee05940bf094ddbed6b0d6 Mon Sep 17 00:00:00 2001 From: horker Date: Mon, 19 Mar 2018 22:27:34 +0900 Subject: [PATCH] Fix a bug in grouping --- templates/OxyPlotCli.template.psd1 | 5 ++++- templates/XYSeries.template.ps1 | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/templates/OxyPlotCli.template.psd1 b/templates/OxyPlotCli.template.psd1 index cb4efff..7832c96 100644 --- a/templates/OxyPlotCli.template.psd1 +++ b/templates/OxyPlotCli.template.psd1 @@ -12,7 +12,7 @@ RootModule = 'OxyPlotCli.psm1' # Version number of this module. -ModuleVersion = '1.0.2' +ModuleVersion = '1.0.3' # Supported PSEditions # CompatiblePSEditions = '' @@ -222,6 +222,9 @@ PrivateData = @{ # ReleaseNotes of this module ReleaseNotes = @" +v1.0.3 +Bug fix: grouping + v1.0.2 Updated the link to the project site diff --git a/templates/XYSeries.template.ps1 b/templates/XYSeries.template.ps1 index 487b028..f4f697b 100644 --- a/templates/XYSeries.template.ps1 +++ b/templates/XYSeries.template.ps1 @@ -157,18 +157,18 @@ end { foreach ($e in $GroupData) { $groups[$e] = 1 } - if ($GroupKeys.Count -eq 0) { - $groupKeys = $groups.Keys | Sort + if ($GroupingKeys.Count -eq 0) { + $GroupingKeys = $groups.Keys | Sort } $grouping = $true } else { - $groupKeys = @("dummy") + $GroupingKeys = @("dummy") $grouping = $false } $dataCount = $<% $SeriesElement.Element[0].Name %>Data.Count - foreach ($group in $groupKeys) { + foreach ($group in $GroupingKeys) { <% } # if ($SeriesElement -ne $null) -%> $series = New-Object <% $ClassName %> @@ -180,6 +180,7 @@ end { <% } # if ($SeriesElement -ne $null) -%> <% if ($SeriesElement -ne $null) { -%> + $catCount = 0; for ($i = 0; $i -lt $dataCount; ++$i) { if ($grouping -and $GroupData[$i] -ne $group) { continue @@ -188,10 +189,11 @@ end { <% if ($e.Name -ne "CategoryIndex") { -%> if ($i -lt $<% $e.Name %>Data.Count) { $<% $e.Name %>Element = $<% $e.Name %>Data[$i] } else { $<% $e.Name %>Element = $null } <% } else { -%> - if ($i -lt $CategoryIndexData.Count) { $CategoryIndexElement = $CategoryIndexData[$i] } else { $CategoryIndexElement = $i } + if ($i -lt $CategoryIndexData.Count) { $CategoryIndexElement = $CategoryIndexData[$i] } else { $CategoryIndexElement = $catCount } <% } -%> <% } -%> <% $SeriesElement.Cmdlet %> $series<% $SeriesElement.Element | where { $_.Name -ne "Category" } | foreach { %> $<% $_.Name %>Element<% } %> + ++$catCount } <% } # if ($SeriesElement -ne $null) -%> @@ -202,7 +204,15 @@ end { if ($<% $YAxisElement.Name %>Data.Count -gt 0) { $info.YDataType = Get-ValueType $<% $YAxisElement.Name %>Data[0] } <% } -%> <% if ($SeriesElement -ne $null -and $SeriesElement.Element.Name -Contains "Category") { -%> - $info.CategoryNames = $CategoryData + + if ($grouping) { + $info.CategoryNames = New-Object Collections.Generic.List[string] + for ($i = 0; $i -lt $dataCount; ++$i) { + if ($GroupData[$i] -eq $GroupingKeys[0]) { + $info.CategoryNames.Add($CategoryData[$i]) + } + } + } <% } -%> $series = $series | Add-Member -PassThru NoteProperty _Info $info