I’m testing out a Nivo pie chart and I’d like to launch an external URL when clicking on one of the data elements in the chart. I’ve included a URL in the data, and using a toast message like this returns the correct data with URL:
Show-UDToast -Message $EventData
However, I then tried to use:
but nothing happens when I click on the data element. I can run this same command in the design terminal, but I’m guessing that maybe a new process can’t be launched from the OnClick event? Is there any way to achieve this, either with a Nivo chart or a different component?
You can use Invoke-UDRedirect to redirect the user on click.
Nice! However, I also figured out my issue. I was handling the event data as an object, rather than raw json. I changed it to:
Start-Process (convertfrom-json $EventData).Url
and it worked. I’ll check out the redirect as well.
I’d like to launch the external URL in a new tab or window, and it doesn’t look like UDRedirect will do that.
Was taking a look at that since it’s marked as a good first issue - looks like you may have already taken care of it!
@adamdriscoll - do you know of a way to refer to the clicked data element in an onClick scriptblock for a UDChart? For instance, if I click on a pie wedge, can I customize the action based on which wedge I clicked on?
I can’t find a way to do this currently, which is why I was looking at the Nivo chart since I can use
$EventData to achieve this.
Hey Matt, I’m working on a similar project, were you ever able to get this figured out?
Which part? Launching a URL or clicking on a pie wedge?
Both – launching URL on pie wedge click
Yeah, I was able to launch the URL, but had to use start-process which is a little wonky.