Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$i is undefined in Else clauses when -IncludeLegend and -LegendText parameterset used #10

Open
jzabroski opened this issue Mar 9, 2018 · 0 comments

Comments

@jzabroski
Copy link
Contributor

Arrange

 Invoke-WebRequest -Uri "http://data.githubarchive.org/2015-01-01-12.json.gz" -OutFile githubarchive2012-01-01-12.json.gz"
 Install-Module PS7Zip -Repository PSGallery -Scope CurrentUser
 Set-ExecutionPolicy RemoteSigned -CurrentUser
 Import-Module PS7Zip
 Expand-7Zip .\githubarchive2012-01-01-12.json.gz
 $data = Get-Content .\githubarchive2012-01-01-12.json | ConvertFrom-Json
 Import-Module .\PoshCharts.psm1
 $plottable = $data | group type;
 $legend = $plottable | select -ExpandProperty name

Act 1

 $plottable | Out-ColumnChart -XField Name -YField Count -IncludeLegend -LegendText $legend -Title "# of Events"

Assert 1

  # Should not throw error - fails

Actual 1

Index operation failed; the array index evaluated to null.
At C:\source\PoshCharts\PoshCharts\Functions\Public\Out-ColumnChart.ps1:172 char:21

  • ... $chart.Series[$SeriesLabel].LegendText = $LegendText[($i- ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArrayIndex

Act 2

 $data | group type | Out-AreaChart -XField Name -YField Count -IncludeLegend -LegendText $legend -Title "# of Events"

Assert 2

 # Should not throw error - fails

Actual 2

Index operation failed; the array index evaluated to null.
At C:\source\PoshCharts\PoshCharts\Functions\Public\Out-AreaChart.ps1:172 char:21

  • ... $chart.Series[$SeriesLabel].LegendText = $LegendText[($i- ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArrayIndex

Act 3

$data | group type | Out-BarChart -XField Name -YField Count -IncludeLegend -LegendText $legend -Title "# of Events"

Assert 3

 # Should not throw error - fails

Actual 3

Index operation failed; the array index evaluated to null.
At C:\source\PoshCharts\PoshCharts\Functions\Public\Out-BarChart.ps1:172 char:21

  • ... $chart.Series[$SeriesLabel].LegendText = $LegendText[($i- ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArrayIndex

etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant