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

Values with decimals do not auto-find within html table when clicking on charts/pies #209

Closed high101bro closed 3 years ago

high101bro commented 3 years ago

Issue:

When clicking on a chart/pie, the html table does not lookup/find data that contains strings with decimals. In my example, the name keys contain IP addresses that I want to quickly lookup in the html table. My own current personal fix is replacing decimals with comas, though this is a band-aide fix for linking the data... not search-friendly though.

Expected Actions:

My datasets have values with decimals in them. Clicking on the charts/pies should easily find data within the html table without me having to modify the data.

# Define data
$DataTable = @(
    [PSCustomObject] @{
        Name  = '192.168.0.1'
        ComputerName = 'host1'
    }
    [PSCustomObject] @{
        Name  = '192.168.0.2'
        ComputerName = 'host2'
    }
    [PSCustomObject] @{
        Name  = '192.168.0.3'
        ComputerName = 'host3'
    }
)

# Define HTML

New-HTML {
    New-HTMLTable -DataTable $DataTable -DataTableID 'NewIDtoSearchInChart'
    New-HTMLChart {
        New-ChartToolbar -Download
        foreach ($Object in $DataTable) {
            New-ChartPie -Name $Object.Name -Value $Object.Time
        }
        # Define event
        New-ChartEvent -DataTableID 'NewIDtoSearchInChart' -ColumnID 0
    }
} -ShowHTML -FilePath $PSScriptRoot\Example-ChartsWithTablesPie.html -Online #-Format
PrzemyslawKlys commented 3 years ago

Your example isn't working - it uses non-existing Time property. Pie charts needs Value to show charts as far as I understand them. Upon fixing example I was able to reproduce it and fixing the issue.

# Define data
$DataTable = @(
    [PSCustomObject] @{
        Name         = '192.168.0.1'
        ComputerName = 'host1'
        Value        = 12
    }
    [PSCustomObject] @{
        Name         = '192.168.0.2'
        ComputerName = 'host2'
        Value        = 15
    }
    [PSCustomObject] @{
        Name         = '192.168.0.3'
        ComputerName = 'host3'
        Value        = 17
    }
)

# Define HTML
New-HTML {
    New-HTMLTable -DataTable $DataTable -DataTableID 'NewIDtoSearchInChart'
    New-HTMLChart {
        New-ChartToolbar -Download
        foreach ($Object in $DataTable) {
            New-ChartPie -Name $Object.Name -Value $Object.Value
        }
        # Define event
        New-ChartEvent -DataTableID 'NewIDtoSearchInChart' -ColumnID 0
    }
} -ShowHTML -FilePath $PSScriptRoot\Example-ChartsWithTablesDecimal.html -Online #-Format

There were 2 problems:

This is now fixed and will be in the next release.