Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify target in href links #1171

Closed
jakevdp opened this issue Feb 28, 2018 · 6 comments
Closed

Specify target in href links #1171

jakevdp opened this issue Feb 28, 2018 · 6 comments
Assignees
Labels
enhancement For enhancement of existing features

Comments

@jakevdp
Copy link
Contributor

jakevdp commented Feb 28, 2018

It would be useful to be able to specify the target in href links within vega plots. One example is plots within the Jupyter notebook, for which a normal <a href=""> changes the window and can lead to a loss of state.

It would be nice to let this percolate up to Vega-Lite as well 😄

@jakevdp jakevdp changed the title Specify target in href links Specify target in href links Feb 28, 2018
@domoritz
Copy link
Member

As a workaround, for now, you can add some code to the page to show a warning before state is lost. https://stackoverflow.com/a/1119324/214950

@jheer jheer added the enhancement For enhancement of existing features label Feb 28, 2018
@jheer
Copy link
Member

jheer commented Feb 28, 2018

Note that if you shift-click you should get the link to open in a new tab. At least, that works in a normal web deployment of Vega.

@jheer jheer self-assigned this Feb 28, 2018
@jheer
Copy link
Member

jheer commented Feb 28, 2018

TODOs to service this request:

  1. Update vega-view to ensure shared view.loader is passed to scenegraph handler instance.
  2. Update vega-loader to include a 'target' option to set global href link target.

jheer added a commit to vega/vega-view that referenced this issue Mar 1, 2018
@jheer
Copy link
Member

jheer commented Mar 5, 2018

Added via updates to vega-view and vega-loader. Once the next Vega version is released, the following will set the default link target within the URL sanitization and loading system:

new vega.View(runtimeSpec, {
  loader: vega.loader({target: '_blank'})
});

Perhaps vega-embed should also be updated to expose target as a parameter?

@ted-dunstone
Copy link

Would it be possible to provide a simple example showing how this could be achieved (updating the target) in a jupterlab notebook?

@domoritz
Copy link
Member

I don't have the time to make a full example right now but I think you can just pass a dictionary with {'target': '_blank'} to the Vega-Embed loader option property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement For enhancement of existing features
Projects
None yet
Development

No branches or pull requests

4 participants