Add hyperlinks in the linked charts ex

Hello @Greg !
I am still exploring the possibilities of your Deneb Example - Linked Charts - Deneb Showcase - Enterprise DNA Forum

I wanted to try and add an hyperlink to the top 20 table, as per https://vega.github.io/vega-lite/docs/encoding.html#href.
So you would click on the text, and it would take you to the google search page of the team.

Now, it does not work… the transform is OK, the url seems fine, but I don’t see the cursor changing and no action happens when I click on the table.

I put the code in the last mark:
{
“mark”: {
“type”: “text”,
“color”: “black”,
“fontWeight”: “bold”
},
“encoding”: {
“href”: {
“field”: “url”,
“type”: “nominal”
},
“text”: {
“field”: “value”
}
}
}

How would you make it work?

Deneb Examples - Linked Charts - Scatter and Top 20 Table - V2 - Hyperlink question.pbix (1.4 MB)

Thanks!
Kind regards
Valeria

Hi @valeriabreveglieri

Never tried (nor seen) URLs before in a Deneb visual, so checked the Vega-Lite documentation and found this:

Just add an “href” encoding to the mark you want to be clickable.

Here’s the code:

{
  "title": {
    "text": "eDNA Forum - Deneb URL",
    "anchor": "start",
    "font": "Verdana",
    "fontSize": 24
  },
  "data": {"name": "dataset"},
  "encoding": {
    "y": {
      "field": "Name",
      "type": "nominal"
    }
  },
  "layer": [
    {
      "name": "BAR",
      "mark": {"type": "bar"},
      "encoding": {
        "x": {
          "field": "ID",
          "type": "quantitative"
        },
        "href": {
          "field": "URL",
          "type": "nominal"
        }
      }
    }
  ]
}

Hope it helps.
Greg
eDNA Forum - Deneb URL.pbix (1.3 MB)

Hi Valeria.

Apologies for the previous message … I read your first post first thing this morning and thought it was simple … its not.

I had another thought that it might be the fold transform that is preventing the hyperlink from working in your example, but duplicated one of my interim “work” pages for the top 20 table, added the href, and it seems to work.

Not sure why it’s not working in the main composite visual. I tried moving the transform for the URL inside the top 20 table, but that still didn’t help things.

For what its worth, here’s my work-in-progress PBIX:
eDNA Forum - Deneb Hyperlinks.pbix (1.4 MB)

Hope it helps.
Greg

2 Likes

Hello @Greg , thanks!
Yes, I did not know you could add hyperlinks either, but a user asked me to do so for a good reason, so I checked it out and I was surprised you not only can but in a supposedly easy way.
Yes the fold does not seem to be the issue - I don’t have it in my chart and it still does not work. Interestingly, if you move the href to the scatter plot, it does work:

I tried to remove the filtering/brush from the chart to see if that could be the issue for the hyperlinks not working in the table, without success…

Thanks
Kind regards
Valeria

Hello @Greg !
I discussed with @dm-p who gave me the explanation and answer which I wanted to share with you :slight_smile:
The trick is to make sure the __row__ field is passed to the “table”, which is not by default. In my chart for example, that has cross-filtering enabled, I noticed I was able to select a point of the scatterplot but not from the text marks.
To force Vega-lite to get the __row__, it was enough in both this case and my case to pass it on as a tooltip (file attached).

I hope it can help other people attempting to do the same! It really is a neat feature.

Kind regards
Valeria

eDNA Forum - Deneb Hyperlinks (2).pbix (1.4 MB)

2 Likes