question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

href opening new browser window/tab

See original GitHub issue

Hello,

In the code below, is it possible to change the href behaviour to opening the URL in a new browser window/tab?

import altair as alt
from vega_datasets import data
from urllib.parse import urlencode

def make_google_query(name):
    return "https://www.google.com/search?" + urlencode({'q': '"{0}"'.format(name)})

cars = data.cars()
cars['url'] = cars['Name'].apply(make_google_query)

alt.Chart(cars).mark_circle(size=60).encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin',
    href='url',
    tooltip=['Name', 'url']
)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
joelostblomcommented, May 14, 2022

Answered on SO: https://stackoverflow.com/questions/72238350/how-to-open-url-from-altair-chart-in-a-new-tab-href/, you can set the usermeta on the chart dictionary:

chart['usermeta'] = {
    "embedOptions": {
        'loader': {'target': '_blank'}
    }
}
3reactions
jakevdpcommented, Aug 15, 2019

No, there’s no way to do this, unfortumately. See https://github.com/vega/vega-lite/issues/3795

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Open a Link in a New Tab – HTML target blank ...
You can use the target="_blank" attribute if you want your users to click on a link that opens up a new browser tab....
Read more >
How to Make Links Open in a New Window or Tab
How to Open Hyperlinks in a New Browser Tab or Window ... The short answer is: just add a target="_blank" attribute to your...
Read more >
Open link in new tab or window [duplicate]
Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration and how they click on the...
Read more >
The a target attribute
If you set the target attribute to "_blank", the link will open in a new browser window or a new tab.
Read more >
HTML link in a new window
Open a link in a new window or tab. In order to open a link in a new window / tab, add target="_blank"...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found