Launch URL from Nivo OnClick event


#1

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:

Start-Process $EventData.URL

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?


#2

You can use Invoke-UDRedirect to redirect the user on click.


#3

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.


#4

I’d like to launch the external URL in a new tab or window, and it doesn’t look like UDRedirect will do that.


#5

Ah. Yep: https://github.com/ironmansoftware/universal-dashboard/issues/440


#6

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!


#7

@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.


#8

Hey Matt, I’m working on a similar project, were you ever able to get this figured out?


#9

Which part? Launching a URL or clicking on a pie wedge?


#10

Both – launching URL on pie wedge click


#11

Yeah, I was able to launch the URL, but had to use start-process which is a little wonky.