UniversalDashboard.Funnel.psm1

$IndexJs = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($IndexJs.FullName)

function New-UDFunnel {
    <#
    .SYNOPSIS
    Creates a new funnel chart component

    .DESCRIPTION
    Creates a new funnel chart component that can be customised via the paramters

    .EXAMPLE
    Please visit https://psdevuk.github.io/ud-flix/React-Funnel-Pipeline/ for example usage and information
    #>


    param(
        [Parameter()]
        [string]$Id = (New-Guid).ToString(), #Allows you to give this component an ID to reference it
        [Parameter()]
        [string]$Title, #Shows a title above the funnel chart
        [Parameter()]
        [switch]$showValues, #Shows the actual value in the funnel for which the value represents in the chart
        [Parameter()]
        [switch]$showNames, #Shows the name representing the section of the funnel chart
        [Parameter()]
        [switch]$showRunningTotal,  #Instead of showing the value in the segment it will show the running total of all values underneath it
        [Parameter()]
        [int]$chartWidth, #Numerical value to control the width of the chart
        [Parameter()]
        [int]$chartHeight, #Numerical value to control the height of the chart
        [Parameter()]
        [switch]$heightRelativeToValue, #Each segment will have its own height relative to the value
        [Parameter(Mandatory)]
        [array]$Data, #Mandatory array of data
        [Parameter(Mandatory)]
        [array]$Colors #Mandatory array of colours to render the funnel chart colours
    )

    End {
        @{
            assetId = $AssetId
            isPlugin = $true
            type = "ud-funnel"
            id = $Id

            title = $Title
            showValues = $showValues.IsPresent
            showNames = $showNames.IsPresent
            showRunningTotal = $showRunningTotal.IsPresent
            chartWidth = $chartWidth
            chartHeight = $chartHeight
            heightRelativeToValue = $heightRelativeToValue.IsPresent
            data = $Data
            pallette = $Colors

        }
    }
}