I’m attempting to built a “Parent Chart” and a “Child Chart.” Whenever a data element is clicked in the Parent Chart the Child Chart should refresh showing further details for the selected element. This is what I have so far but I’m not sure what the syntax for the onClick function should be.
Parent Chart:
New-UdChart -Title "Parent Chart" -Type Bar -FontColor white -OnClick ( New-UDEndpoint -Endpoint { $Cache:SecLookup = Invoke-WebRequest http://localhost:10001/api/TransLookUp/$($ArgumentList[0]) | ConvertFrom-Json Sync-UDElement -Id 'ChildChart' } -ArgumentList $(($EventData | ConvertFrom-Json).label) ) -Endpoint { $Cache:ParentData = Invoke-SqlCmd2 -ServerInstance $SQLServer -Database $SQLDB -Query $SpentBySection -As PSObject $Cache:ParentData | ForEach-Object { [PSCustomObject]@{ SecNo = $_.SecNumber; TotRev = $_.TotalRev; TotSpent = $_.TotalSpent; } } | Out-UDChartData -LabelProperty SecNo -Dataset @( New-UDChartDataset -DataProperty "TotSpent" -Label "Total Spent" -BackgroundColor "#80962F23" -HoverBackgroundColor "#80962F23" New-UDChartDataset -DataProperty "TotRev" -Label "Total Revenue" -BackgroundColor "#8014558C" -HoverBackgroundColor "#8014558C" ) }
Rest API
$TransactionLookUp += New-UDEndpoint -Url ‘TransLookUp/:SecID’ -Endpoint{
param($SecID)$Cache:BudgetData | Where-Object SectionID -EQ $SecID | ConvertTo-Json}
Start-UDRestApi -Endpoint $TransactionLookUp -Port 10001 -AutoReload
Child Chart:
New-UDElement -Id 'ChildChart' -Tag 'div' -Endpoint { New-UdChart -Title "Child Chart" -Type Bar -FontColor white -Endpoint { $Cache:SecLookup | ForEach-Object { [PSCustomObject]@{ AccNo = $_.AccNumber; TotSpent = $_.TotalSpent; } }| Out-UDChartData -LabelProperty AccNo -Dataset @( New-UDChartDataset -DataProperty "TotSpent" -Label "Total Spent" -BackgroundColor "green" ) } }