-
-
Notifications
You must be signed in to change notification settings - Fork 477
/
echarts.py
65 lines (48 loc) · 1.5 KB
/
echarts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Defines custom bokeh model to render ECharts plots.
"""
from bokeh.core.properties import (
Any, Dict, Enum, List, Nullable, String,
)
from bokeh.events import ModelEvent
from bokeh.models import LayoutDOM
from ..config import config
from ..io.resources import bundled_files
from ..util import classproperty
class EChartsEvent(ModelEvent):
event_name = 'echarts_event'
def __init__(self, model, type=None, data=None, query=None):
self.type = type
self.data = data
self.query = query
super().__init__(model=model)
class ECharts(LayoutDOM):
"""
A Bokeh model that wraps around an ECharts plot and renders it
inside a Bokeh.
"""
__javascript_raw__ = [
f"{config.npm_cdn}/echarts@5.4.1/dist/echarts.min.js",
f"{config.npm_cdn}/echarts-gl@2.0.9/dist/echarts-gl.min.js"
]
@classproperty
def __javascript__(cls):
return bundled_files(cls)
@classproperty
def __js_skip__(cls):
return {
'echarts': cls.__javascript__[:1]
}
__js_require__ = {
'paths': {
"echarts": f"{config.npm_cdn}/echarts@5.4.1/dist/echarts.min",
"echarts-gl": f"{config.npm_cdn}/echarts-gl@2.0.9/dist/echarts-gl.min"
},
'exports': {}
}
data = Nullable(Dict(String, Any))
options = Nullable(Dict(String, Any))
event_config = Dict(String, Any)
js_events = Dict(String, List(Any))
renderer = Enum("canvas", "svg")
theme = String("default")