EvotecIT / PSWriteHTML

PSWriteHTML is PowerShell Module to generate beautiful HTML reports, pages, emails without any knowledge of HTML, CSS or JavaScript. To get started basics PowerShell knowledge is required.
MIT License
826 stars 106 forks source link

ChartLine empty when first 2 values are 0 & XAxis values #235

Closed amanfromfrance closed 3 years ago

amanfromfrance commented 3 years ago

Hello PrzemyslawKlys,

I am opening an issue on GitHub so that my problem is easier to track (sorry for my emails).

I am trying to plot line charts and while it was working as expected using the old "Dashimo" module, I've noticed that now with "PSWriteHTML" I have an issue with the data that is set as the ChartLine values.

For example in the code below the 2 first values are 0s:

$test = @(
@{date="May  4"; time="00:02:47"; participantNumber=0}
@{date="May  4"; time="00:07:47"; participantNumber=0}
@{date="May  4"; time="00:12:47"; participantNumber=3}
@{date="May  4"; time="00:17:47"; participantNumber=2}
@{date="May  4"; time="00:22:47"; participantNumber=1}
@{date="May  4"; time="00:27:47"; participantNumber=2}
@{date="May  4"; time="00:32:47"; participantNumber=3}
@{date="May  4"; time="00:37:47"; participantNumber=4}
@{date="May  4"; time="00:42:47"; participantNumber=5}
@{date="May  4"; time="00:47:47"; participantNumber=10})

New-HTML -TitleText 'Charts - TimeLine' -Online -FilePath "C:\ChartLine.html" {
    New-HTMLSection  -Name 'Total number of Calls' -Collapsable -TextBackGroundColor "#000000" -TextColor "#ff7900" {
        New-HTMLPanel -Invisible {
            New-HTMLChart {
                New-ChartAxisX -Name $test.time
                ChartLegend -Name 'Calls Number'
                New-ChartLine -Name 'Participants Number' -Value $test.participantNumber -Color "#ff7900" 
                New-ChartAxisY -Show -TitleText 'Time'
            }
        }
    }
}

Instead of the line chart I see only one plot:

2021-05-05_100738

If I replace the 2 first values with digits greater than 0:

$test = @(
@{date="May  4"; time="00:02:47"; participantNumber=5}
@{date="May  4"; time="00:07:47"; participantNumber=4}
@{date="May  4"; time="00:12:47"; participantNumber=3}
@{date="May  4"; time="00:17:47"; participantNumber=2}
@{date="May  4"; time="00:22:47"; participantNumber=1}
@{date="May  4"; time="00:27:47"; participantNumber=2}
@{date="May  4"; time="00:32:47"; participantNumber=3}
@{date="May  4"; time="00:37:47"; participantNumber=4}
@{date="May  4"; time="00:42:47"; participantNumber=5}
@{date="May  4"; time="00:47:47"; participantNumber=10})

Now the graph displays:

2021-05-05_100512

However, the time values are replaced by an index value and everything I tried was unsuccessful.

Thanks!

PrzemyslawKlys commented 3 years ago

Try giving a type

   New-ChartAxisX -Name $test.time -Type datetime
PrzemyslawKlys commented 3 years ago

Your problems with zeros is the same as https://github.com/EvotecIT/PSWriteHTML/issues/234 and it's now fixed in sources and it will be released to preview later on today

amanfromfrance commented 3 years ago

Thanks for your feedback PrzemyslawKlys!

Try giving a type

   New-ChartAxisX -Name $test.time -Type datetime

I have tried this with no sucess, I still see the index values.

I saw what you explained in #234 and tried to install the pre-release module using your command:

Install-Module PSWriteHTML -AllowPrerelease

With this version I only get empty charts:

image

PrzemyslawKlys commented 3 years ago

Nah, it's not released with a fix for you. But once I release it, it should work.

PrzemyslawKlys commented 3 years ago

image

That's what I get on my version:

Import-Module .\PSWriteHTML.psd1 -Force

$test = @(
    @{date = "May  4"; time = "00:02:47"; participantNumber = 0 }
    @{date = "May  4"; time = "00:07:47"; participantNumber = 0 }
    @{date = "May  4"; time = "00:12:47"; participantNumber = 3 }
    @{date = "May  4"; time = "00:17:47"; participantNumber = 2 }
    @{date = "May  4"; time = "00:22:47"; participantNumber = 1 }
    @{date = "May  4"; time = "00:27:47"; participantNumber = 2 }
    @{date = "May  4"; time = "00:32:47"; participantNumber = 3 }
    @{date = "May  4"; time = "00:37:47"; participantNumber = 4 }
    @{date = "May  4"; time = "00:42:47"; participantNumber = 5 }
    @{date = "May  4"; time = "00:47:47"; participantNumber = 10 })

New-HTML -TitleText 'Charts - TimeLine' -Online -FilePath "$PSScriptRoot\Example-ChartsLine1.html" {
    New-HTMLSection -Name 'Total number of Calls' -Collapsable -TextBackGroundColor "#000000" -TextColor "#ff7900" {
        New-HTMLPanel -Invisible {
            New-HTMLChart {
                New-ChartAxisX -Name $test.time
                ChartLegend -Name 'Calls Number'
                New-ChartLine -Name 'Participants Number' -Value $test.participantNumber -Color "#ff7900"
                New-ChartAxisY -Show -TitleText 'Time'
            }
        }
    }
} -ShowHTML
PrzemyslawKlys commented 3 years ago

You can try it yourself, now.

Install-Module PSWriteHTML -AllowPrerelease
amanfromfrance commented 3 years ago

indeed, now it works! Thanks for your support PrzemyslawKlys!