Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions altair/vegalite/v6/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ def to_html(
**kwargs,
)

def to_url(self, *, fullscreen: bool = False) -> str:
def to_url(self, *, fullscreen: bool = False, validate: bool = True) -> str:
"""
Convert a chart to a URL that opens the chart specification in the Vega chart editor.

Expand All @@ -2285,27 +2285,35 @@ def to_url(self, *, fullscreen: bool = False) -> str:
----------
fullscreen : bool
If True, editor will open chart in fullscreen mode. Default False
validate : boolean
If True, then validate the input against the schema.
"""
from altair.utils._importers import import_vl_convert

vlc = import_vl_convert()
if _using_vegafusion():
return vlc.vega_to_url(self.to_dict(format="vega"), fullscreen=fullscreen)
return vlc.vega_to_url(
self.to_dict(format="vega", validate=validate), fullscreen=fullscreen
)
else:
return vlc.vegalite_to_url(self.to_dict(), fullscreen=fullscreen)
return vlc.vegalite_to_url(
self.to_dict(validate=validate), fullscreen=fullscreen
)

def open_editor(self, *, fullscreen: bool = False) -> None:
def open_editor(self, *, fullscreen: bool = False, validate: bool = True) -> None:
"""
Opens the chart specification in the Vega chart editor using the default browser.

Parameters
----------
fullscreen : bool
If True, editor will open chart in fullscreen mode. Default False
validate : boolean
If True, then validate the input against the schema.
"""
import webbrowser

webbrowser.open(self.to_url(fullscreen=fullscreen))
webbrowser.open(self.to_url(fullscreen=fullscreen, validate=validate))

def save(
self,
Expand Down