diff --git a/Code/Classes/003.pshtml.components.charts.ps1 b/Code/Classes/003.pshtml.components.charts.ps1 index eeab4827..1118f0c3 100644 --- a/Code/Classes/003.pshtml.components.charts.ps1 +++ b/Code/Classes/003.pshtml.components.charts.ps1 @@ -403,11 +403,8 @@ Class ChartAnimation { } Class ChartOptions { - [int]$barPercentage = 0.9 [Int]$categoryPercentage = 0.8 [bool]$responsive = $false - [String]$barThickness - [Int]$maxBarThickness [Bool] $offsetGridLines = $true [scales]$scales = [scales]::New() [ChartTitle]$title = [ChartTitle]::New() @@ -435,7 +432,9 @@ Class ChartOptions { #region Charts Class BarChartOptions : ChartOptions { - + [int]$barPercentage = 0.9 + [String]$barThickness + [Int]$maxBarThickness } Class horizontalBarChartOptions : ChartOptions { diff --git a/PSHTML/Examples/Charts/Chart01/Chart1.ps1 b/PSHTML/Examples/Charts/Chart01/Chart1.ps1 index 22fdbf90..3449ddb9 100644 --- a/PSHTML/Examples/Charts/Chart01/Chart1.ps1 +++ b/PSHTML/Examples/Charts/Chart01/Chart1.ps1 @@ -35,7 +35,7 @@ $HTMLPage = html { $Data3 = @(4,1,6,12,17,25,18,17,22,30,35,44) $Labels = @("January","February","Mars","April","Mai","June","July","August","September","October","November","december") - $dsb3 = New-PSHTMLChartBarDataSet -Data $data3 -label "2018" -BackgroundColor ([Color]::blue ) + $dsb3 = New-PSHTMLChartBarDataSet -Data $data3 -label "2018" -BackgroundColor "blue" New-PSHTMLChart -type bar -DataSet $dsb3 -title "Bar Chart Example" -Labels $Labels -CanvasID $BarCanvasID diff --git a/PSHTML/Examples/Charts/Chart04/4Charts.ps1 b/PSHTML/Examples/Charts/Chart04/4Charts.ps1 index d4976813..030d354b 100644 --- a/PSHTML/Examples/Charts/Chart04/4Charts.ps1 +++ b/PSHTML/Examples/Charts/Chart04/4Charts.ps1 @@ -51,7 +51,7 @@ $HTMLPage = html { script -src "https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js" -type "text/javascript" - #script -content { + script -content { $Data1 = @(34,7,11,19) $Data2 = @(40,2,13,17) @@ -59,17 +59,16 @@ $HTMLPage = html { $Labels = @("Closed","Unresolved","Pending","Open") - $dsb1 = New-PSHTMLChartBarDataSet -Data $data1 -label "March" -BackgroundColor ([Color]::Orange) - $dsb2 = New-PSHTMLChartBarDataSet -Data $data2 -label "April" -BackgroundColor ([Color]::red) - $dsb3 = New-PSHTMLChartBarDataSet -Data $data3 -label "Mai" -BackgroundColor ([Color]::Green ) + $dsb1 = New-PSHTMLChartBarDataSet -Data $data1 -label "March" -BackgroundColor "Orange" + $dsb2 = New-PSHTMLChartBarDataSet -Data $data2 -label "April" -BackgroundColor "red" + $dsb3 = New-PSHTMLChartBarDataSet -Data $data3 -label "Mai" -BackgroundColor "Green" New-PSHTMLChart -type bar -DataSet $dsb1,$dsb2,$dsb3 -title "Bar Chart v2" -Labels $Labels -CanvasID $BarCanvasID -tobase64 - $red = [Color]::red $dsl1 = New-PSHTMLChartLineDataSet -lineColor "cyan" -Data $data1 -label "March" - $dsl2 = New-PSHTMLChartLineDataSet -Data $data2 -label "April" -LineColor ([Color]::Orange ) - $dsl3 = New-PSHTMLChartLineDataSet -Data $data3 -label "Mai" -LineColor ([Color]::Green) + $dsl2 = New-PSHTMLChartLineDataSet -Data $data2 -label "April" -LineColor "Orange" + $dsl3 = New-PSHTMLChartLineDataSet -Data $data3 -label "Mai" -LineColor "Green" New-PSHTMLChart -type Line -DataSet @($dsl1,$dsl2,$dsl3) -title "Line Chart v2" -Labels $Labels -CanvasID $lineCanvasID -tobase64 @@ -83,14 +82,14 @@ $HTMLPage = html { $colors = @("yellow","red","green","orange") $dsd1 = New-PSHTMLChartDoughnutDataSet -Data $data1 -label "March" -backgroundcolor $colors -hoverbackgroundColor $Colors - $dsd2 = New-PSHTMLChartDoughnutDataSet -Data $data2 -label "April" -BackgroundColor ([Color]::red) - $dsd3 = New-PSHTMLChartDoughnutDataSet -Data $data3 -label "Mai" -BackgroundColor ([Color]::Green ) + $dsd2 = New-PSHTMLChartDoughnutDataSet -Data $data2 -label "April" -BackgroundColor "red" + $dsd3 = New-PSHTMLChartDoughnutDataSet -Data $data3 -label "Mai" -BackgroundColor "green" New-PSHTMLChart -type doughnut -DataSet @($dsd1) -title "Doughnut Chart v2" -Labels $Labels -CanvasID $DoughnutCanvasID -tobase64 - #} + } } diff --git a/PSHTML/Examples/Charts/Chart05/BasicBarChart.ps1 b/PSHTML/Examples/Charts/Chart05/BasicBarChart.ps1 index f979b0da..785f564d 100644 --- a/PSHTML/Examples/Charts/Chart05/BasicBarChart.ps1 +++ b/PSHTML/Examples/Charts/Chart05/BasicBarChart.ps1 @@ -33,7 +33,7 @@ $HTMLPage = html { $Labels = @("Closed","Unresolved","Pending","Open") - $dsb1 = New-PSHTMLChartBarDataSet -Data $data1 -label "March" -BackgroundColor ([Color]::blue) + $dsb1 = New-PSHTMLChartBarDataSet -Data $data1 -label "March" -BackgroundColor "blue" New-PSHTMLChart -type bar -DataSet $dsb1 -title "Ticket Statistics" -Labels $Labels -CanvasID $BarCanvasID diff --git a/PSHTML/Examples/Charts/Chart06/BasicPieChart.ps1 b/PSHTML/Examples/Charts/Chart06/BasicPieChart.ps1 index 304ee733..2129e760 100644 --- a/PSHTML/Examples/Charts/Chart06/BasicPieChart.ps1 +++ b/PSHTML/Examples/Charts/Chart06/BasicPieChart.ps1 @@ -45,6 +45,6 @@ $HTMLPage = html { } -$OutPath = $Home\BasicPieChart.html" +$OutPath = "$Home\BasicPieChart.html" $HTMLPage | out-file -FilePath $OutPath -Encoding utf8 start $outpath \ No newline at end of file diff --git a/PSHTML/Examples/Charts/Chart10/PolarAreaChart.ps1 b/PSHTML/Examples/Charts/Chart10/PolarAreaChart.ps1 index 763fc264..d22eb0b3 100644 --- a/PSHTML/Examples/Charts/Chart10/PolarAreaChart.ps1 +++ b/PSHTML/Examples/Charts/Chart10/PolarAreaChart.ps1 @@ -32,7 +32,7 @@ $HTMLDocument = html { $HoverColors = @('DarkGreen', 'yellow', 'Orange', 'grey', 'DarkGrey', 'blue', 'Magenta', 'DarkMagenta', 'red', 'Cyan', 'DarkCyan', 'green' ) $Data1 = @(17, 25, 18, 17, 10, 28, 35, 50, 44, 10, 32, 72) - $dsb1 = New-PSHTMLChartPolarAreaDataSet -Data $data1 -BackgroundColor $Colors -hoverBackgroundColor $HoverColors -PointRadius + $dsb1 = New-PSHTMLChartPolarAreaDataSet -Data $data1 -BackgroundColor $Colors -hoverBackgroundColor $HoverColors New-PSHTMLChart -type polarArea -DataSet $dsb1 -title 'PolarArea Chart Example' -Labels $Labels -CanvasID $PolarCanvasID } diff --git a/PSHTML/PSHTML.psd1 b/PSHTML/PSHTML.psd1 index cbc1b916..f38eea75 100644 --- a/PSHTML/PSHTML.psd1 +++ b/PSHTML/PSHTML.psd1 @@ -1,9 +1,9 @@ # -# Module manifest for module 'PSHTML' +# Module manifest for module 'PSGet_PSHTML' # # Generated by: Stéphane van Gulick # -# Generated on: 20/10/2019 +# Generated on: 21.10.2019 # @{ @@ -32,13 +32,13 @@ Copyright = '(c) 2018 Stéphane van Gulick. All rights reserved.' # Description of the functionality provided by this module Description = 'Cross platform PowerShell module to generate HTML markup language and create awesome web pages!' -# Minimum version of the PowerShell engine required by this module +# Minimum version of the Windows PowerShell engine required by this module PowerShellVersion = '5.0' -# Name of the PowerShell host required by this module +# Name of the Windows PowerShell host required by this module # PowerShellHostName = '' -# Minimum version of the PowerShell host required by this module +# Minimum version of the Windows PowerShell host required by this module # PowerShellHostVersion = '' # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. @@ -127,17 +127,11 @@ PrivateData = @{ # ReleaseNotes of this module ReleaseNotes = 'https://github.com/Stephanevg/PSHTML/blob/master/Change_Log.md' - # Prerelease string of this module - # Prerelease = '' - - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # ExternalModuleDependencies = '' } # End of PSData hashtable - + } # End of PrivateData hashtable # HelpInfo URI of this module diff --git a/PSHTML/PSHTML.psm1 b/PSHTML/PSHTML.psm1 index c3c88177..8e947ab6 100644 --- a/PSHTML/PSHTML.psm1 +++ b/PSHTML/PSHTML.psm1 @@ -1,4 +1,4 @@ -#Generated at 10/20/2019 14:37:20 by Stephane van Gulick +#Generated at 10/21/2019 07:29:59 by Stephane van Gulick Enum SettingType { General @@ -735,7 +735,7 @@ Class LogFile : LogDocument { } }else{ - $cp = (Get-PSCallStack)[-1].ScriptName #$PSCommandPath #Split-Path -parent $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(�.\�) #$PSCommandPath + $cp = (Get-PSCallStack)[-1].ScriptName #$PSCommandPath #Split-Path -parent $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(�.\�) #$PSCommandPath } $cp = $global:MyInvocation.MyCommand.Definition #fix for Ubuntu appveyor machines. @@ -798,7 +798,7 @@ Class LogFile : LogDocument { } hidden [string] CreateFileName() { - $cp = $PSCommandPath #Split-Path -parent $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(�.\�) #$PSCommandPath + $cp = $PSCommandPath #Split-Path -parent $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(�.\�) #$PSCommandPath if(!($cp)){ $cp = (Get-PSCallStack)[-1].ScriptName } @@ -1316,11 +1316,8 @@ Class ChartAnimation { } Class ChartOptions { - [int]$barPercentage = 0.9 [Int]$categoryPercentage = 0.8 [bool]$responsive = $false - [String]$barThickness - [Int]$maxBarThickness [Bool] $offsetGridLines = $true [scales]$scales = [scales]::New() [ChartTitle]$title = [ChartTitle]::New() @@ -1348,7 +1345,9 @@ Class ChartOptions { #region Charts Class BarChartOptions : ChartOptions { - + [int]$barPercentage = 0.9 + [String]$barThickness + [Int]$maxBarThickness } Class horizontalBarChartOptions : ChartOptions { @@ -2571,7 +2570,7 @@ Function base { base "woop1" -Class "class" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Current Version: 3.1 History: 2018.11.1; Stephanevg;Updated to version 3.1 @@ -2813,7 +2812,7 @@ Function button { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1 History: 2018.11.1; Stephanevg;Updated to version 3.1 @@ -3853,7 +3852,7 @@ Function fieldset { fieldset {$css} -media "print" -type "text/css" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -4322,7 +4321,7 @@ function Get-PSHTMLAsset { .OUTPUTS Asset[] .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick .Link https://github.com/Stephanevg/PSHTML #> @@ -4783,7 +4782,7 @@ Function H1 { h1 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -4837,7 +4836,7 @@ Function h2 { h2 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -4889,7 +4888,7 @@ Function h3 { h3 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -4941,7 +4940,7 @@ Function h4 { h4 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -4993,7 +4992,7 @@ Function h5 { h5 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -5045,7 +5044,7 @@ Function h6 { h6 {"woop3"} -Class "class" -Id "MaintTitle" -Style "color:red;" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -5273,7 +5272,7 @@ Function hr {
.Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 2.0.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -5736,7 +5735,7 @@ Function label { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 1.0.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -5792,7 +5791,7 @@ Function legend { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -5939,7 +5938,7 @@ Function Link { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -6178,7 +6177,7 @@ Function meta { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -6370,7 +6369,7 @@ Function nav { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -6884,7 +6883,7 @@ Function New-PSHTMLChartDataSet { .OUTPUTS [DataSet] .NOTES - Author: Stéphane van Gulick + Author: Stéphane van Gulick #> [CmdletBInding()] Param( @@ -7831,7 +7830,7 @@ Function optgroup { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -7964,7 +7963,7 @@ function Out-PSHTMLDocument { .DESCRIPTION Output the html string into a file. .EXAMPLE - The following example gets the list of first 5 processes. Converts it into an HTML Table. It outputs the results in a file, and opens the results imédiatley. + The following example gets the list of first 5 processes. Converts it into an HTML Table. It outputs the results in a file, and opens the results imédiatley. $o = Get-PRocess | select ProcessName,Handles | select -first 5 $FilePath = "C:\temp\OutputFile.html" @@ -7977,7 +7976,7 @@ function Out-PSHTMLDocument { None .NOTES - Author: Stéphane van Gulick + Author: Stéphane van Gulick .LINK @@ -8470,7 +8469,7 @@ Function selecttag { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.2.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -8530,7 +8529,7 @@ Function small { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -8645,7 +8644,7 @@ Function strong { .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 @@ -8704,7 +8703,7 @@ Function style { style {$css} -media "print" -type "text/css" .Notes - Author: Stéphane van Gulick + Author: Stéphane van Gulick Version: 3.1.0 History: 2018.10.30;@ChristopheKumor;Updated to version 3.0 diff --git a/Tests/Chart.New-PSHTMLChart.Tests.ps1 b/Tests/Chart.New-PSHTMLChart.Tests.ps1 index 3aa7019c..e4c897ff 100644 --- a/Tests/Chart.New-PSHTMLChart.Tests.ps1 +++ b/Tests/Chart.New-PSHTMLChart.Tests.ps1 @@ -10,7 +10,7 @@ set-location -Path $RootFolder.FullName Write-Verbose "Importing module" -import-module .\PSHTML -Force +#import-module .\PSHTML -Force InModuleScope PSHTML { @@ -28,10 +28,6 @@ InModuleScope PSHTML { $Data = @(3, 5) $Title = "Test Title" $CanvasID = "TestCanvasID" - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> $bds = New-PSHTMLChartBarDataSet -Data $Data it '[New-PSHTMLChart][-Type Bar][-DataSet BarDataSet][Label][Title][CanvasId] Should not throw' { @@ -42,96 +38,22 @@ InModuleScope PSHTML { $Is = New-PSHTMLChart -Type bar -DataSet $bds -Labels $Labels -Title $Title -CanvasID $CanvasID #don't touche this part, as the regex is very 'fragile' - <# $Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); -var myChart = new Chart(ctx, { - "type": "bar", - "data": { - "labels": [ - "january", - "february" - ], - "datasets": [ - { - "borderWidth": 1, - "xAxisID": null, - "yAxisID": null, - "backgroundColor": null, - "borderColor": null, - "borderSkipped": null, - "hoverBackgroundColor": null, - "hoverBorderColor": null, - "hoverBorderWidth": 0, - "data": [ - - ], - "label": null - } - ] - }, - "options": { - "barPercentage": 1, - "categoryPercentage": 1, - "responsive": false, - "barThickness": null, - "maxBarThickness": 0, - "offsetGridLines": true, - "scales": { - "yAxes": [ - { - "ticks": { - "beginAtZero": true - } - } - ], - "xAxes": [ - - ] - }, - "title": { - "display": true, - "text": "Test Title" - }, - "animation": { - "onComplete":null - } - } -} -); -'@ -#> - -<# - -$Should = @' - -'@ -#> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"bar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"xAxisID":null,"yAxisID":null,"backgroundColor":null,"borderColor":"","borderSkipped":null,"hoverBackgroundColor":null,"hoverBorderColor":null,"hoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"bar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"xAxisID":null,"yAxisID":null,"backgroundColor":null,"borderColor":"","borderSkipped":null,"hoverBackgroundColor":null,"hoverBorderColor":null,"hoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"barPercentage":1,"barThickness":null,"maxBarThickness":0,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ $Is | should be $Should } - - - } -tag "Chart", "Bar" Describe "Testing New-PSHTMLChart -Type horizontalBar" { - $Labels = @("january", "february") $Data = @(3, 5) $Title = "Test Title" $CanvasID = "TestCanvasID" - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> + $bds = New-PSHTMLChartBarDataSet -Data $Data it '[New-PSHTMLChart][-Type horizontalBar][-DataSet BarDataSet][Label][Title][CanvasId] Should not throw' { @@ -141,28 +63,15 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart it '[New-PSHTMLChart][-Type horizontalBar][-DataSet BarDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { $Is = New-PSHTMLChart -Type horizontalBar -DataSet $bds -Labels $Labels -Title $Title -CanvasID $CanvasID -<# - -$Should = @' - -'@ -#> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"horizontalBar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"xAxisID":null,"yAxisID":null,"backgroundColor":null,"borderColor":"","borderSkipped":null,"hoverBackgroundColor":null,"hoverBorderColor":null,"hoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"horizontalBar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"xAxisID":null,"yAxisID":null,"backgroundColor":null,"borderColor":"","borderSkipped":null,"hoverBackgroundColor":null,"hoverBorderColor":null,"hoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - #$Is | should be $Should - + $Is | should be $Should } - - - } -tag "Chart", "horizontalBar" Describe "Testing New-PSHTMLChart -Type Radar" { - - $Labels = @("january", "february") $Title = "Test Title" $CanvasID = "TestCanvasID" @@ -183,12 +92,12 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart If($PSVersionTable.PsEdition -eq 'Core'){ $Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"radar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"pointBackgroundColor":"rgba(0, 0, 0, 0.1)","pointBorderColor":"rgba(0, 0, 0, 0.1)","pointBorderWidth":[1],"pointRadius":2.0,"pointStyle":"circle","xAxisID":null,"yAxisID":null,"backgroundColor":"transparent","borderColor":"rgb(0,0,255)","borderSkipped":null,"hoverBackgroundColor":"rgb(0,128,0)","hoverBorderColor":null,"hoverBorderWidth":0,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"data":[17,25,18,17,22,30,35,44,4,1,6,12],"label":["2018"]}]},"options":{"scales":null,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"radar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"pointBackgroundColor":"rgba(0, 0, 0, 0.1)","pointBorderColor":"rgba(0, 0, 0, 0.1)","pointBorderWidth":[1],"pointRadius":2.0,"pointStyle":"circle","xAxisID":null,"yAxisID":null,"backgroundColor":"transparent","borderColor":"rgb(0,0,255)","borderSkipped":null,"hoverBackgroundColor":"rgb(0,128,0)","hoverBorderColor":null,"hoverBorderWidth":0,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"data":[17,25,18,17,22,30,35,44,4,1,6,12],"label":["2018"]}]},"options":{"scales":null,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ } else { $Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"radar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"pointBackgroundColor":"rgba(0, 0, 0, 0.1)","pointBorderColor":"rgba(0, 0, 0, 0.1)","pointBorderWidth":[1],"pointRadius":2,"pointStyle":"circle","xAxisID":null,"yAxisID":null,"backgroundColor":"transparent","borderColor":"rgb(0,0,255)","borderSkipped":null,"hoverBackgroundColor":"rgb(0,128,0)","hoverBorderColor":null,"hoverBorderWidth":0,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"data":[17,25,18,17,22,30,35,44,4,1,6,12],"label":["2018"]}]},"options":{"scales":null,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"radar","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"pointBackgroundColor":"rgba(0, 0, 0, 0.1)","pointBorderColor":"rgba(0, 0, 0, 0.1)","pointBorderWidth":[1],"pointRadius":2,"pointStyle":"circle","xAxisID":null,"yAxisID":null,"backgroundColor":"transparent","borderColor":"rgb(0,0,255)","borderSkipped":null,"hoverBackgroundColor":"rgb(0,128,0)","hoverBorderColor":null,"hoverBorderWidth":0,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"data":[17,25,18,17,22,30,35,44,4,1,6,12],"label":["2018"]}]},"options":{"scales":null,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ } @@ -207,10 +116,6 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart $Title = "Test Title" $CanvasID = "TestCanvasID" $BackgroundColor = @('red', 'green', 'yellow', 'grey', 'blue') - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> it '[New-PSHTMLChartPolarAreaDataSet][-Data $Data][-BackgroundColor $BackgroundColor][-label $Labels] Should not throw' { { New-PSHTMLChartPolarAreaDataSet -Data $Data -BackgroundColor $BackgroundColor -label $Labels } | should not throw @@ -223,18 +128,10 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart it '[New-PSHTMLChart][-Type polarArea][-DataSet BarDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { $Is = New-PSHTMLChart -Type polarArea -DataSet $bds -Labels $Labels -Title $Title -CanvasID $CanvasID -<# -$Should = @' - -'@ -#> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"polarArea","data":{"labels":["red","green","yellow","grey","blue"],"datasets":[{"borderWidth":1,"backgroundColor":["red","green","yellow","grey","blue"],"borderColor":[""],"borderSkipped":null,"hoverBackgroundColor":[""],"hoverBorderColor":[""],"hoverBorderWidth":0,"data":[3,5,7,2,9],"label":["red","green","yellow","grey","blue"]}]},"options":{"scales":null,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"polarArea","data":{"labels":["red","green","yellow","grey","blue"],"datasets":[{"borderWidth":1,"backgroundColor":["red","green","yellow","grey","blue"],"borderColor":[""],"borderSkipped":null,"hoverBackgroundColor":[""],"hoverBorderColor":[""],"hoverBorderWidth":0,"data":[3,5,7,2,9],"label":["red","green","yellow","grey","blue"]}]},"options":{"scales":null,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - - #$Is | should be $Should $Is | should be $Should } @@ -250,10 +147,7 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart $Data = @(3, 5) $Title = "Test Title" $CanvasID = "TestCanvasID" - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> + $TestData = New-PSHTMLChartPieDataSet -Data $Data it '[New-PSHTMLChart][-Type Pie][-DataSet PieDataSet][Label][Title][CanvasId] Should not throw' { @@ -261,97 +155,23 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart } it '[New-PSHTMLChart][-Type Bar][-DataSet PieDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { - $IsTemp = New-PSHTMLChart -Type Pie -DataSet $TestData -Labels $Labels -Title $Title -CanvasID $CanvasID - #$Is = $IsTemp.Trim() - <# - $Should =@' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); -var myChart = new Chart(ctx, { - "type": "pie", - "data": { - "labels": [ - "january", - "february" - ], - "datasets": [ - { - "borderColor": "white", - "borderWidth": 1, - "backgroundColor": null, - "hoverBackgroundColor": [ - null - ], - "HoverBorderColor": null, - "HoverBorderWidth": 0, - "data": [ - 3, - 5 - ], - "label": null - } - ] - }, - "options": { - "barPercentage": 1, - "categoryPercentage": 1, - "responsive": false, - "barThickness": null, - "maxBarThickness": 0, - "offsetGridLines": true, - "scales": { - "yAxes": [ - { - "ticks": { - "beginAtZero": true - } - } - ], - "xAxes": [ - - ] - }, - "title": { - "display": true, - "text": "Test Title" - }, - "animation": { - "onComplete":null - } - } -} -); -'@ - -#> - -<# + $Is = New-PSHTMLChart -Type Pie -DataSet $TestData -Labels $Labels -Title $Title -CanvasID $CanvasID -$Should = @' - -'@ -#> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"pie","data":{"labels":["january","february"],"datasets":[{"borderColor":"white","borderWidth":1,"backgroundColor":null,"hoverBackgroundColor":[null],"HoverBorderColor":null,"HoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"pie","data":{"labels":["january","february"],"datasets":[{"borderColor":"white","borderWidth":1,"backgroundColor":null,"hoverBackgroundColor":[null],"HoverBorderColor":null,"HoverBorderWidth":0,"data":[3,5],"label":null}]},"options":{"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - $IsTemp | should be $Should + $Is | should be $Should } } -Tag "Chart","Pie" Describe "Testing New-PSHTMLChart -Type Doughnut" { - - $Title = "Test Title" $CanvasID = "TestCanvasID" $Data1 = @(34,7,11,19) $Labels = @("Closed","Unresolved","Pending","Open") $colors = @("LightGreen","Red","LightBlue","LightYellow") - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> $TestData = New-PSHTMLChartDoughnutDataSet -Data $data1 -label "March" -backgroundcolor $colors @@ -362,105 +182,19 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart it '[New-PSHTMLChart][-Type Doughnut][-DataSet PieDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { $Is = New-PSHTMLChart -Type Doughnut -DataSet $TestData -Labels $Labels -Title $Title -CanvasID $CanvasID - #$Is = $Is.Trim() - <# -$Should =@' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); -var myChart = new Chart(ctx, { - "type": "doughnut", - "data": { - "labels": [ - "Closed", - "Unresolved", - "Pending", - "Open" - ], - "datasets": [ - { - "borderColor": "white", - "borderWidth": 1, - "backgroundColor": [ - "LightGreen", - "Red", - "LightBlue", - "LightYellow" - ], - "hoverBackgroundColor": [ - "LightGreen", - "Red", - "LightBlue", - "LightYellow" - ], - "HoverBorderColor": null, - "HoverBorderWidth": 0, - "data": [ - 34, - 7, - 11, - 19 - ], - "label": "March" - } - ] - }, - "options": { - "barPercentage": 1, - "categoryPercentage": 1, - "responsive": false, - "barThickness": null, - "maxBarThickness": 0, - "offsetGridLines": true, - "scales": { - "yAxes": [ - { - "ticks": { - "beginAtZero": true - } - } - ], - "xAxes": [ - - ] - }, - "title": { - "display": true, - "text": "Test Title" - }, - "animation": { - "onComplete":null - } - } -} -); -'@ -#> - -<# - -$Should = @' - -'@ -#> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"doughnut","data":{"labels":["Closed","Unresolved","Pending","Open"],"datasets":[{"borderColor":"white","borderWidth":1,"backgroundColor":["LightGreen","Red","LightBlue","LightYellow"],"hoverBackgroundColor":["LightGreen","Red","LightBlue","LightYellow"],"HoverBorderColor":null,"HoverBorderWidth":0,"data":[34,7,11,19],"label":["March"]}]},"options":{"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"doughnut","data":{"labels":["Closed","Unresolved","Pending","Open"],"datasets":[{"borderColor":"white","borderWidth":1,"backgroundColor":["LightGreen","Red","LightBlue","LightYellow"],"hoverBackgroundColor":["LightGreen","Red","LightBlue","LightYellow"],"HoverBorderColor":null,"HoverBorderWidth":0,"data":[34,7,11,19],"label":["March"]}]},"options":{"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ $Is | should be $Should } } -Tag "Chart","Doughnut" Describe "Testing New-PSHTMLChart -Type Line" { - - $Labels = @("january", "february") $Data = @(3, 5) $Data2 = @(12, 15) $Title = "Test Title" $CanvasID = "TestCanvasID" - #$bds = - <# mock -CommandName New-PSHTMLChartBarDataSet -MockWith { - New-MockObject -Type "datasetbar" - } #> $bds = New-PSHTMLChartLineDataSet -Data $Data $bds2 = New-PSHTMLChartLineDataSet -Data $Data2 @@ -470,132 +204,33 @@ var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart it '[New-PSHTMLChart][-Type Line][-DataSet LineDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { $Is = New-PSHTMLChart -Type Line -DataSet $bds -Labels $Labels -Title $Title -CanvasID $CanvasID - #don't touche this part, as the regex is very 'fragile' -<# -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); -var myChart = new Chart(ctx, { - "type": "line", - "data": { - "labels": [ - "january", - "february" - ], - "datasets": [ - { - "borderWidth": 1, - "borderDash": [ - 0 - ], - "borderDashOffSet": 0, - "cubicInterpolationMode": "default", - "fill": false, - "lineTension": 0.5, - "pointBackgroundColor": "rgb(255,255,255)", - "pointBorderColor": "rgb(0,0,0)", - "pointBorderWidth": [ - 1 - ], - "pointRadius": 4, - "pointStyle": "circle", - "showLine": true, - "backgroundColor": null, - "borderColor": null, - "borderCapStyle": null, - "borderJoinStyle": null, - "pointRotation": null, - "pointHitRadius": null, - "PointHoverBackgroundColor": null, - "pointHoverBorderColor": null, - "pointHoverBorderWidth": 0, - "pointHoverRadius": null, - "spanGaps": false, - "data": [ - - ], - "label": null - } - ] - }, - "options": { - "showLines": true, - "spanGaps": false, - "barPercentage": 1, - "categoryPercentage": 1, - "responsive": false, - "barThickness": null, - "maxBarThickness": 0, - "offsetGridLines": true, - "scales": { - "yAxes": [ - { - "ticks": { - "beginAtZero": true - } - } - ], - "xAxes": [ - - ] - }, - "title": { - "display": true, - "text": "Test Title" - }, - "animation": { - "onComplete":null - } - } -} -); -'@ -#> - -If($PSVersionTable.PsEdition -eq 'Core'){ - - <# - - $Should = @' - -'@ - #> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[3,5],"label":null}]},"options":{"showLines":true,"spanGaps":false,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); -'@ -}else{ - - <# - - $Should = @' - + If($PSVersionTable.PsEdition -eq 'Core'){ + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[3,5],"label":null}]},"options":{"showLines":true,"spanGaps":false,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - #> - -$Should = @' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[3,5],"label":null}]},"options":{"showLines":true,"spanGaps":false,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + } + else{ + $Should = @' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[3,5],"label":null}]},"options":{"showLines":true,"spanGaps":false,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ + } -} - - $Is | should be $Should + $Is | should be $Should } it '[New-PSHTMLChart][-Type Line][-DataSet Multiple LineDataSet][Label][Title][CanvasId] Should create ChartJS javascript Code' { $Is = New-PSHTMLChart -Type Line -DataSet $bds,$bds2 -Labels $Labels -Title $Title -CanvasID $CanvasID If($PSVersionTable.PsEdition -eq 'Core'){ - $Should =@' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[3,5],"label":null},{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[12,15],"label":null}]},"options":{"showLines":true,"spanGaps":false,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + $Should =@' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[3,5],"label":null},{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4.0,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0.0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0.0,"spanGaps":false,"data":[12,15],"label":null}]},"options":{"showLines":true,"spanGaps":false,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - }Else{ - $Should =@' -var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[3,5],"label":null},{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[12,15],"label":null}]},"options":{"showLines":true,"spanGaps":false,"barPercentage":1,"categoryPercentage":1,"responsive":false,"barThickness":null,"maxBarThickness":0,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); + }Else{ + $Should =@' +var ctx = document.getElementById("TestCanvasID").getContext('2d'); var myChart = new Chart(ctx, {"type":"line","data":{"labels":["january","february"],"datasets":[{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[3,5],"label":null},{"borderWidth":1,"borderDash":[0],"borderDashOffSet":0,"cubicInterpolationMode":"default","fill":false,"lineTension":0.5,"pointBackgroundColor":"rgb(255,255,255)","pointBorderColor":"rgb(0,0,0)","pointBorderWidth":[1],"pointRadius":4,"pointStyle":"circle","showLine":true,"backgroundColor":null,"borderColor":null,"borderCapStyle":null,"borderJoinStyle":null,"pointRotation":null,"pointHitRadius":0,"PointHoverBackgroundColor":null,"pointHoverBorderColor":null,"pointHoverBorderWidth":0,"pointHoverRadius":0,"spanGaps":false,"data":[12,15],"label":null}]},"options":{"showLines":true,"spanGaps":false,"categoryPercentage":1,"responsive":false,"offsetGridLines":true,"scales":{"yAxes":[{"ticks":{"beginAtZero":true}}],"xAxes":[""]},"title":{"display":true,"text":"Test Title"},"animation":{"onComplete":null}}} ); '@ - } + } $Is | should be $Should } - - } -tag "Chart", "Line" } diff --git a/docs/Charts/Charts.PolarArea.md b/docs/Charts/Charts.PolarArea.md index 53161a98..8fb0d7f8 100644 --- a/docs/Charts/Charts.PolarArea.md +++ b/docs/Charts/Charts.PolarArea.md @@ -9,7 +9,6 @@ In the following example, we create a Polar Area chart dataset, with labels, specific colors, and the data of course. - ```powershell $Labels = @('January', 'February', 'Mars', 'April', 'Mai', 'June', 'July', 'August', 'September', 'October', 'November', 'december') @@ -19,8 +18,6 @@ $HoverColors = @('DarkGreen', 'yellow', 'Orange', 'grey', 'DarkGrey', 'blu $dsb1 = New-PSHTMLChartPolarAreaDataSet -Data $data1 -BackgroundColor $Colors -hoverBackgroundColor $HoverColors - - ``` > It is important to keep in mind, that the array of values which are past through each parameter going hand in hand together. diff --git a/docs/Charts/Charts.Radar.md b/docs/Charts/Charts.Radar.md index 2165e6b7..00219043 100644 --- a/docs/Charts/Charts.Radar.md +++ b/docs/Charts/Charts.Radar.md @@ -7,13 +7,14 @@ ```powershell $Labels = @("January","February","Mars","April","Mai","June","July","August","September","October","November","december") - $dsb1 = @() + $Data1 = @(17,25,18,17,22,30,35,44,4,1,6,12) +$dsb1 += New-PSHTMLChartRadarDataSet -Data $data1 -label "2018" -borderColor (get-pshtmlColor -color blue) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color green) -PointRadius 2 $Data2 = @(4,1,6,12,17,25,18,17,22,30,35,44) +$dsb1 += New-PSHTMLChartRadarDataSet -Data $data2 -label "2019" -borderColor (get-pshtmlColor -color red) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color yellow) -PointRadius 10 -pointBackgroundColor (get-pshtmlColor -color red) -pointBorderColor (get-pshtmlColor -color blue) -$dsb1 += New-PSHTMLChartBarDataSet -Data $data1 -label "2018" -borderColor (get-pshtmlColor -color blue) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color green) -$dsb1 += New-PSHTMLChartBarDataSet -Data $data2 -label "2019" -borderColor (get-pshtmlColor -color red) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color yellow) +New-PSHTMLChart -type radar -DataSet $dsb1 -title "Radar Chart Example" -Labels $Labels -CanvasID $radarCanvasID ``` > Use `Get-PSHTMLColor -Color` and tab through the results @@ -58,9 +59,9 @@ $HTMLDocument = html { $dsb1 = @() $Data1 = @(17,25,18,17,22,30,35,44,4,1,6,12) - $dsb1 += New-PSHTMLChartBarDataSet -Data $data1 -label "2018" -borderColor (get-pshtmlColor -color blue) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color green) + $dsb1 += New-PSHTMLChartRadarDataSet -Data $data1 -label "2018" -borderColor (get-pshtmlColor -color blue) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color green) -PointRadius 2 $Data2 = @(4,1,6,12,17,25,18,17,22,30,35,44) - $dsb1 += New-PSHTMLChartBarDataSet -Data $data2 -label "2019" -borderColor (get-pshtmlColor -color red) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color yellow) + $dsb1 += New-PSHTMLChartRadarDataSet -Data $data2 -label "2019" -borderColor (get-pshtmlColor -color red) -backgroundColor "transparent" -hoverBackgroundColor (get-pshtmlColor -color yellow) -PointRadius 10 -pointBackgroundColor (get-pshtmlColor -color red) -pointBorderColor (get-pshtmlColor -color blue) New-PSHTMLChart -type radar -DataSet $dsb1 -title "Radar Chart Example" -Labels $Labels -CanvasID $radarCanvasID