Skip to content

Commit

Permalink
feat: Plot and card animations. (#2126)
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci authored Sep 6, 2023
1 parent 54c0553 commit 9a790fd
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 42 deletions.
1 change: 1 addition & 0 deletions py/examples/tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def get_wave_completions(line, character, file_content):
q.page['meta'] = ui.meta_card(
box='',
title=app_title,
animate=True,
scripts=[ui.script(q.app.tour_assets + '/loader.min.js')],
script=ui.inline_script(content=template, requires=['require'], targets=['monaco-editor']),
layouts=[
Expand Down
30 changes: 30 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5626,6 +5626,7 @@ def __init__(
visible: Optional[bool] = None,
events: Optional[List[str]] = None,
interactions: Optional[List[str]] = None,
animate: Optional[bool] = None,
):
_guard_scalar('Visualization.plot', plot, (Plot,), False, False, False)
_guard_scalar('Visualization.width', width, (str,), False, True, False)
Expand All @@ -5634,6 +5635,7 @@ def __init__(
_guard_scalar('Visualization.visible', visible, (bool,), False, True, False)
_guard_vector('Visualization.events', events, (str,), False, True, False)
_guard_vector('Visualization.interactions', interactions, (str,), False, True, False)
_guard_scalar('Visualization.animate', animate, (bool,), False, True, False)
self.plot = plot
"""The plot to be rendered in this visualization."""
self.data = data
Expand All @@ -5650,6 +5652,8 @@ def __init__(
"""The events to capture on this visualization. One of 'select_marks'."""
self.interactions = interactions
"""The interactions to be allowed for this plot. One of 'drag_move' | 'scale_zoom' | 'brush'. Note: `brush` does not raise `select_marks` event."""
self.animate = animate
"""EXPERIMENTAL: True to turn on the chart animations. Defaults to False."""

def dump(self) -> Dict:
"""Returns the contents of this object as a dict."""
Expand All @@ -5660,6 +5664,7 @@ def dump(self) -> Dict:
_guard_scalar('Visualization.visible', self.visible, (bool,), False, True, False)
_guard_vector('Visualization.events', self.events, (str,), False, True, False)
_guard_vector('Visualization.interactions', self.interactions, (str,), False, True, False)
_guard_scalar('Visualization.animate', self.animate, (bool,), False, True, False)
return _dump(
plot=self.plot.dump(),
data=self.data,
Expand All @@ -5669,6 +5674,7 @@ def dump(self) -> Dict:
visible=self.visible,
events=self.events,
interactions=self.interactions,
animate=self.animate,
)

@staticmethod
Expand All @@ -5689,6 +5695,8 @@ def load(__d: Dict) -> 'Visualization':
_guard_vector('Visualization.events', __d_events, (str,), False, True, False)
__d_interactions: Any = __d.get('interactions')
_guard_vector('Visualization.interactions', __d_interactions, (str,), False, True, False)
__d_animate: Any = __d.get('animate')
_guard_scalar('Visualization.animate', __d_animate, (bool,), False, True, False)
plot: Plot = Plot.load(__d_plot)
data: PackedRecord = __d_data
width: Optional[str] = __d_width
Expand All @@ -5697,6 +5705,7 @@ def load(__d: Dict) -> 'Visualization':
visible: Optional[bool] = __d_visible
events: Optional[List[str]] = __d_events
interactions: Optional[List[str]] = __d_interactions
animate: Optional[bool] = __d_animate
return Visualization(
plot,
data,
Expand All @@ -5706,6 +5715,7 @@ def load(__d: Dict) -> 'Visualization':
visible,
events,
interactions,
animate,
)


Expand Down Expand Up @@ -10620,6 +10630,7 @@ def __init__(
script: Optional[InlineScript] = None,
stylesheet: Optional[InlineStylesheet] = None,
stylesheets: Optional[List[Stylesheet]] = None,
animate: Optional[bool] = None,
commands: Optional[List[Command]] = None,
):
_guard_scalar('MetaCard.box', box, (str,), False, False, False)
Expand All @@ -10639,6 +10650,7 @@ def __init__(
_guard_scalar('MetaCard.script', script, (InlineScript,), False, True, False)
_guard_scalar('MetaCard.stylesheet', stylesheet, (InlineStylesheet,), False, True, False)
_guard_vector('MetaCard.stylesheets', stylesheets, (Stylesheet,), False, True, False)
_guard_scalar('MetaCard.animate', animate, (bool,), False, True, False)
_guard_vector('MetaCard.commands', commands, (Command,), False, True, False)
self.box = box
"""A string indicating how to place this component on the page."""
Expand Down Expand Up @@ -10674,6 +10686,8 @@ def __init__(
"""CSS stylesheet to be applied to this page."""
self.stylesheets = stylesheets
"""External CSS files to load into the page."""
self.animate = animate
"""EXPERIMENTAL: True to turn on the card animations. Defaults to False."""
self.commands = commands
"""Contextual menu commands for this component."""

Expand All @@ -10696,6 +10710,7 @@ def dump(self) -> Dict:
_guard_scalar('MetaCard.script', self.script, (InlineScript,), False, True, False)
_guard_scalar('MetaCard.stylesheet', self.stylesheet, (InlineStylesheet,), False, True, False)
_guard_vector('MetaCard.stylesheets', self.stylesheets, (Stylesheet,), False, True, False)
_guard_scalar('MetaCard.animate', self.animate, (bool,), False, True, False)
_guard_vector('MetaCard.commands', self.commands, (Command,), False, True, False)
return _dump(
view='meta',
Expand All @@ -10716,6 +10731,7 @@ def dump(self) -> Dict:
script=None if self.script is None else self.script.dump(),
stylesheet=None if self.stylesheet is None else self.stylesheet.dump(),
stylesheets=None if self.stylesheets is None else [__e.dump() for __e in self.stylesheets],
animate=self.animate,
commands=None if self.commands is None else [__e.dump() for __e in self.commands],
)

Expand Down Expand Up @@ -10756,6 +10772,8 @@ def load(__d: Dict) -> 'MetaCard':
_guard_scalar('MetaCard.stylesheet', __d_stylesheet, (dict,), False, True, False)
__d_stylesheets: Any = __d.get('stylesheets')
_guard_vector('MetaCard.stylesheets', __d_stylesheets, (dict,), False, True, False)
__d_animate: Any = __d.get('animate')
_guard_scalar('MetaCard.animate', __d_animate, (bool,), False, True, False)
__d_commands: Any = __d.get('commands')
_guard_vector('MetaCard.commands', __d_commands, (dict,), False, True, False)
box: str = __d_box
Expand All @@ -10775,6 +10793,7 @@ def load(__d: Dict) -> 'MetaCard':
script: Optional[InlineScript] = None if __d_script is None else InlineScript.load(__d_script)
stylesheet: Optional[InlineStylesheet] = None if __d_stylesheet is None else InlineStylesheet.load(__d_stylesheet)
stylesheets: Optional[List[Stylesheet]] = None if __d_stylesheets is None else [Stylesheet.load(__e) for __e in __d_stylesheets]
animate: Optional[bool] = __d_animate
commands: Optional[List[Command]] = None if __d_commands is None else [Command.load(__e) for __e in __d_commands]
return MetaCard(
box,
Expand All @@ -10794,6 +10813,7 @@ def load(__d: Dict) -> 'MetaCard':
script,
stylesheet,
stylesheets,
animate,
commands,
)

Expand Down Expand Up @@ -11017,13 +11037,15 @@ def __init__(
plot: Plot,
events: Optional[List[str]] = None,
interactions: Optional[List[str]] = None,
animate: Optional[bool] = None,
commands: Optional[List[Command]] = None,
):
_guard_scalar('PlotCard.box', box, (str,), False, False, False)
_guard_scalar('PlotCard.title', title, (str,), False, False, False)
_guard_scalar('PlotCard.plot', plot, (Plot,), False, False, False)
_guard_vector('PlotCard.events', events, (str,), False, True, False)
_guard_vector('PlotCard.interactions', interactions, (str,), False, True, False)
_guard_scalar('PlotCard.animate', animate, (bool,), False, True, False)
_guard_vector('PlotCard.commands', commands, (Command,), False, True, False)
self.box = box
"""A string indicating how to place this component on the page."""
Expand All @@ -11037,6 +11059,8 @@ def __init__(
"""The events to capture on this card. One of 'select_marks'."""
self.interactions = interactions
"""The interactions to be allowed for this card. One of 'drag_move' | 'scale_zoom' | 'brush'. Note: `brush` does not raise `select_marks` event."""
self.animate = animate
"""EXPERIMENTAL: True to turn on the chart animations. Defaults to False."""
self.commands = commands
"""Contextual menu commands for this component."""

Expand All @@ -11047,6 +11071,7 @@ def dump(self) -> Dict:
_guard_scalar('PlotCard.plot', self.plot, (Plot,), False, False, False)
_guard_vector('PlotCard.events', self.events, (str,), False, True, False)
_guard_vector('PlotCard.interactions', self.interactions, (str,), False, True, False)
_guard_scalar('PlotCard.animate', self.animate, (bool,), False, True, False)
_guard_vector('PlotCard.commands', self.commands, (Command,), False, True, False)
return _dump(
view='plot',
Expand All @@ -11056,6 +11081,7 @@ def dump(self) -> Dict:
plot=self.plot.dump(),
events=self.events,
interactions=self.interactions,
animate=self.animate,
commands=None if self.commands is None else [__e.dump() for __e in self.commands],
)

Expand All @@ -11073,6 +11099,8 @@ def load(__d: Dict) -> 'PlotCard':
_guard_vector('PlotCard.events', __d_events, (str,), False, True, False)
__d_interactions: Any = __d.get('interactions')
_guard_vector('PlotCard.interactions', __d_interactions, (str,), False, True, False)
__d_animate: Any = __d.get('animate')
_guard_scalar('PlotCard.animate', __d_animate, (bool,), False, True, False)
__d_commands: Any = __d.get('commands')
_guard_vector('PlotCard.commands', __d_commands, (dict,), False, True, False)
box: str = __d_box
Expand All @@ -11081,6 +11109,7 @@ def load(__d: Dict) -> 'PlotCard':
plot: Plot = Plot.load(__d_plot)
events: Optional[List[str]] = __d_events
interactions: Optional[List[str]] = __d_interactions
animate: Optional[bool] = __d_animate
commands: Optional[List[Command]] = None if __d_commands is None else [Command.load(__e) for __e in __d_commands]
return PlotCard(
box,
Expand All @@ -11089,6 +11118,7 @@ def load(__d: Dict) -> 'PlotCard':
plot,
events,
interactions,
animate,
commands,
)

Expand Down
9 changes: 9 additions & 0 deletions py/h2o_lightwave/h2o_lightwave/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,7 @@ def visualization(
visible: Optional[bool] = None,
events: Optional[List[str]] = None,
interactions: Optional[List[str]] = None,
animate: Optional[bool] = None,
) -> Component:
"""Create a visualization for display inside a form.
Expand All @@ -2099,6 +2100,7 @@ def visualization(
visible: True if the component should be visible. Defaults to True.
events: The events to capture on this visualization. One of 'select_marks'.
interactions: The interactions to be allowed for this plot. One of 'drag_move' | 'scale_zoom' | 'brush'. Note: `brush` does not raise `select_marks` event.
animate: EXPERIMENTAL: True to turn on the chart animations. Defaults to False.
Returns:
A `h2o_wave.types.Visualization` instance.
"""
Expand All @@ -2111,6 +2113,7 @@ def visualization(
visible,
events,
interactions,
animate,
))


Expand Down Expand Up @@ -3770,6 +3773,7 @@ def meta_card(
script: Optional[InlineScript] = None,
stylesheet: Optional[InlineStylesheet] = None,
stylesheets: Optional[List[Stylesheet]] = None,
animate: Optional[bool] = None,
commands: Optional[List[Command]] = None,
) -> MetaCard:
"""Represents page-global state.
Expand All @@ -3795,6 +3799,7 @@ def meta_card(
script: Javascript code to execute on this page.
stylesheet: CSS stylesheet to be applied to this page.
stylesheets: External CSS files to load into the page.
animate: EXPERIMENTAL: True to turn on the card animations. Defaults to False.
commands: Contextual menu commands for this component.
Returns:
A `h2o_wave.types.MetaCard` instance.
Expand All @@ -3817,6 +3822,7 @@ def meta_card(
script,
stylesheet,
stylesheets,
animate,
commands,
)

Expand Down Expand Up @@ -3903,6 +3909,7 @@ def plot_card(
plot: Plot,
events: Optional[List[str]] = None,
interactions: Optional[List[str]] = None,
animate: Optional[bool] = None,
commands: Optional[List[Command]] = None,
) -> PlotCard:
"""Create a card displaying a plot.
Expand All @@ -3914,6 +3921,7 @@ def plot_card(
plot: The plot to be displayed in this card.
events: The events to capture on this card. One of 'select_marks'.
interactions: The interactions to be allowed for this card. One of 'drag_move' | 'scale_zoom' | 'brush'. Note: `brush` does not raise `select_marks` event.
animate: EXPERIMENTAL: True to turn on the chart animations. Defaults to False.
commands: Contextual menu commands for this component.
Returns:
A `h2o_wave.types.PlotCard` instance.
Expand All @@ -3925,6 +3933,7 @@ def plot_card(
plot,
events,
interactions,
animate,
commands,
)

Expand Down
Loading

0 comments on commit 9a790fd

Please sign in to comment.