Skip to content

Commit

Permalink
Fix a bug in grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
horker committed Mar 19, 2018
1 parent 3089fa7 commit 665b886
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion templates/OxyPlotCli.template.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'OxyPlotCli.psm1'

# Version number of this module.
ModuleVersion = '1.0.2'
ModuleVersion = '1.0.3'

# Supported PSEditions
# CompatiblePSEditions = ''
Expand Down Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions templates/XYSeries.template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -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
Expand All @@ -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) -%>
Expand All @@ -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
Expand Down

0 comments on commit 665b886

Please sign in to comment.