Coverage for src/ipyvizzu/template.py: 100%
36 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-10 09:30 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-10 09:30 +0000
1"""A module for storing the JavaScript templates."""
3from enum import Enum
6class ChartProperty(Enum):
7 """An enum class for storing chart properties."""
9 CONFIG = "config"
10 """An enum key-value for storing config chart property."""
12 STYLE = "style"
13 """An enum key-value for storing style chart property."""
16class DisplayTarget(Enum):
17 """An enum class for storing chart display options."""
19 BEGIN = "begin"
20 """Display all animation steps after the constructor's cell."""
22 END = "end"
23 """Display all animation steps after the last running cell."""
25 ACTUAL = "actual"
26 """Display the actual animation step after the currently running cell."""
28 MANUAL = "manual"
29 """Display all animation steps after calling a show method."""
32class DisplayTemplate:
33 """A class for storing JavaScript snippet templates."""
35 # pylint: disable=too-few-public-methods
37 IPYVIZZUJS: str = "{ipyvizzujs}"
38 """ipyvizzu JavaScript class."""
40 INIT: str = (
41 "window.ipyvizzu.createChart(element, "
42 + "'{chart_id}', '{vizzu}', '{div_width}', '{div_height}');"
43 )
44 """Call createChart JavaScript method."""
46 ANIMATE: str = (
47 "window.ipyvizzu.animate(element, "
48 + "'{chart_id}', '{anim_id}', '{display_target}', {scroll}, "
49 + "lib => {{ return {chart_target} }}, {chart_anim_opts});"
50 )
51 """Call animate JavaScript method."""
53 FEATURE: str = (
54 "window.ipyvizzu.feature(element, '{chart_id}', '{name}', {enabled});"
55 )
56 """Call feature JavaScript method."""
58 STORE: str = "window.ipyvizzu.store(element, '{chart_id}', '{id}');"
59 """Call store JavaScript method."""
61 SET_EVENT: str = (
62 "window.ipyvizzu.setEvent(element, "
63 + "'{chart_id}', '{id}', '{event}', event => {{ {handler} }});"
64 )
65 """Call setEvent JavaScript method."""
67 CLEAR_EVENT: str = (
68 "window.ipyvizzu.clearEvent(element, '{chart_id}', '{id}', '{event}');"
69 )
70 """Call clearEvent JavaScript method."""
72 LOG: str = "window.ipyvizzu.log(element, '{chart_id}', '{chart_property}');"
73 """Call log JavaScript method."""
75 CONTROL: str = "window.ipyvizzu.control(element, '{method}', {params});"
76 """Call animation control JavaScript methods."""
78 CLEAR_INHIBITSCROLL: str = (
79 "if (window.IpyVizzu) { window.IpyVizzu.clearInhibitScroll(element); }"
80 )
81 """Call clearInhibitScroll JavaScript method if ipyvizzu JavaScript class exists."""