ex4nicegui 0.8.6__py3-none-any.whl → 0.8.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ex4nicegui/reactive/EChartsComponent/ECharts.js +9 -0
- ex4nicegui/reactive/EChartsComponent/ECharts.py +4 -0
- ex4nicegui/reactive/officials/echarts.py +47 -2
- {ex4nicegui-0.8.6.dist-info → ex4nicegui-0.8.7.dist-info}/METADATA +33 -3
- {ex4nicegui-0.8.6.dist-info → ex4nicegui-0.8.7.dist-info}/RECORD +7 -7
- {ex4nicegui-0.8.6.dist-info → ex4nicegui-0.8.7.dist-info}/WHEEL +1 -1
- {ex4nicegui-0.8.6.dist-info → ex4nicegui-0.8.7.dist-info}/LICENSE +0 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import 'echarts'
|
|
2
2
|
import { convertDynamicProperties } from "../../static/utils/dynamic_properties.js";
|
|
3
3
|
|
|
4
|
+
const registerThemeTask = Promise.all(
|
|
5
|
+
(echarts._ex4ng_themes || []).map(async ({ name, url }) => {
|
|
6
|
+
const data = await fetch(url).then(response => response.json());
|
|
7
|
+
echarts.registerTheme(name, data);
|
|
8
|
+
})
|
|
9
|
+
);
|
|
10
|
+
|
|
4
11
|
function collectMapRegisterTask() {
|
|
5
12
|
const tasks = new Map();
|
|
6
13
|
|
|
@@ -57,6 +64,8 @@ export default {
|
|
|
57
64
|
async mounted() {
|
|
58
65
|
await new Promise((resolve) => setTimeout(resolve, 0)); // wait for Tailwind classes to be applied
|
|
59
66
|
|
|
67
|
+
await registerThemeTask;
|
|
68
|
+
|
|
60
69
|
this.chart = echarts.init(this.$el, this.theme, this.initOptions);
|
|
61
70
|
this.resizeObs = new ResizeObserver(this.chart.resize)
|
|
62
71
|
|
|
@@ -28,6 +28,7 @@ class echarts(Element, component="ECharts.js", dependencies=libraries): # type:
|
|
|
28
28
|
options: Optional[dict] = None,
|
|
29
29
|
code: Optional[str] = None,
|
|
30
30
|
init_options: Optional[dict] = None,
|
|
31
|
+
theme: Optional[str] = None,
|
|
31
32
|
) -> None:
|
|
32
33
|
super().__init__()
|
|
33
34
|
|
|
@@ -47,6 +48,9 @@ class echarts(Element, component="ECharts.js", dependencies=libraries): # type:
|
|
|
47
48
|
self._props["initOptions"] = init_options
|
|
48
49
|
self._props["eventTasks"] = {}
|
|
49
50
|
|
|
51
|
+
if theme:
|
|
52
|
+
self._props["theme"] = theme
|
|
53
|
+
|
|
50
54
|
def update_chart(
|
|
51
55
|
self,
|
|
52
56
|
merge_opts: Optional[dict] = None,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import Any, Callable, Dict, List, Union, cast, Optional, Literal
|
|
2
|
+
from typing import Any, Callable, Dict, List, Union, cast, Optional, Literal, ClassVar
|
|
3
3
|
from ex4nicegui.reactive.services.reactive_service import ParameterClassifier
|
|
4
4
|
from ex4nicegui.utils.signals import (
|
|
5
5
|
TGetterOrReadonlyRef,
|
|
@@ -17,10 +17,14 @@ from ex4nicegui.reactive.EChartsComponent.events import EChartsMouseEventArgumen
|
|
|
17
17
|
from nicegui.awaitable_response import AwaitableResponse
|
|
18
18
|
from nicegui import ui, app
|
|
19
19
|
import orjson as json
|
|
20
|
+
from contextvars import ContextVar
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
class EChartsBindableUi(BindableUi[echarts]):
|
|
23
24
|
EChartsMouseEventArguments = EChartsMouseEventArguments
|
|
25
|
+
_CURRENT_THEME: ClassVar[ContextVar[Optional[str]]] = ContextVar(
|
|
26
|
+
"CURRENT_THEME", default=None
|
|
27
|
+
)
|
|
24
28
|
|
|
25
29
|
def __init__(
|
|
26
30
|
self,
|
|
@@ -28,6 +32,8 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
28
32
|
not_merge: TMaybeRef[Union[bool, None]] = None,
|
|
29
33
|
code: Optional[str] = None,
|
|
30
34
|
init_options: Optional[Dict] = None,
|
|
35
|
+
*,
|
|
36
|
+
theme: Optional[str] = None,
|
|
31
37
|
) -> None:
|
|
32
38
|
"""Create a new ECharts instance.
|
|
33
39
|
|
|
@@ -43,10 +49,11 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
43
49
|
pc = ParameterClassifier(
|
|
44
50
|
locals(),
|
|
45
51
|
maybeRefs=["options", "code", "init_options"],
|
|
46
|
-
exclude=["not_merge"],
|
|
52
|
+
exclude=["not_merge", "theme"],
|
|
47
53
|
)
|
|
48
54
|
|
|
49
55
|
value_kws = pc.get_values_kws()
|
|
56
|
+
value_kws["theme"] = theme or self._CURRENT_THEME.get()
|
|
50
57
|
|
|
51
58
|
element = echarts(**value_kws).classes("nicegui-echart")
|
|
52
59
|
|
|
@@ -59,6 +66,44 @@ class EChartsBindableUi(BindableUi[echarts]):
|
|
|
59
66
|
for key, value in pc.get_bindings().items():
|
|
60
67
|
self.bind_prop(key, value) # type: ignore
|
|
61
68
|
|
|
69
|
+
@classmethod
|
|
70
|
+
def register_theme(cls, name: str, theme: Path):
|
|
71
|
+
"""register a new theme to echarts.
|
|
72
|
+
|
|
73
|
+
@see - https://github.com/CrystalWindSnake/ex4nicegui/blob/main/README.en.md#rxuiechartsregister_theme
|
|
74
|
+
@中文文档 - https://gitee.com/carson_add/ex4nicegui/tree/main/#rxuiechartsregister_theme
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
name (str): Theme name.
|
|
78
|
+
theme (Path): Theme file path.
|
|
79
|
+
|
|
80
|
+
## Examples
|
|
81
|
+
.. code-block:: python
|
|
82
|
+
|
|
83
|
+
@ui.page('/)
|
|
84
|
+
def index():
|
|
85
|
+
rxui.echarts.register_theme("my_theme", Path("path/to/my_theme.json"))
|
|
86
|
+
rxui.echarts(opts)
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
url = app.add_static_file(local_file=theme)
|
|
91
|
+
|
|
92
|
+
ui.add_body_html(
|
|
93
|
+
rf"""
|
|
94
|
+
<script type="module">
|
|
95
|
+
import "echarts";
|
|
96
|
+
echarts._ex4ng_themes = echarts._ex4ng_themes || [];
|
|
97
|
+
echarts._ex4ng_themes.push({{
|
|
98
|
+
name: "{name}",
|
|
99
|
+
url: "{url}"
|
|
100
|
+
}});
|
|
101
|
+
</script>
|
|
102
|
+
"""
|
|
103
|
+
)
|
|
104
|
+
cls._CURRENT_THEME.set(name)
|
|
105
|
+
return cls
|
|
106
|
+
|
|
62
107
|
@classmethod
|
|
63
108
|
def register_map(
|
|
64
109
|
cls,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: ex4nicegui
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.7
|
|
4
4
|
Summary: Extension library based on nicegui, providing data responsive,BI functionality modules
|
|
5
|
-
Home-page: https://github.com/CrystalWindSnake/ex4nicegui
|
|
6
5
|
License: MIT
|
|
7
6
|
Keywords: nicegui,ex4nicegui,webui
|
|
8
7
|
Author: CrystalWindSnake
|
|
@@ -15,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Requires-Dist: executing (>=2.0.1,<3.0.0)
|
|
19
19
|
Requires-Dist: nicegui (>=2.0.0,<3.0.0)
|
|
20
20
|
Requires-Dist: signe (>=0.4.22,<0.5.0)
|
|
@@ -458,6 +458,7 @@ class MyApp(rxui.ViewModel):
|
|
|
458
458
|
- [echarts 图表鼠标事件](#echarts-图表鼠标事件)
|
|
459
459
|
- [rxui.echarts.from\_javascript](#rxuiechartsfrom_javascript)
|
|
460
460
|
- [rxui.echarts.register\_map](#rxuiechartsregister_map)
|
|
461
|
+
- [rxui.echarts.register\_theme](#rxuiechartsregister_theme)
|
|
461
462
|
- [tab\_panels](#tab_panels)
|
|
462
463
|
- [lazy\_tab\_panels](#lazy_tab_panels)
|
|
463
464
|
- [scoped\_style](#scoped_style)
|
|
@@ -1346,6 +1347,35 @@ rxui.echarts.register_map(
|
|
|
1346
1347
|
)
|
|
1347
1348
|
```
|
|
1348
1349
|
|
|
1350
|
+
---
|
|
1351
|
+
##### rxui.echarts.register_theme
|
|
1352
|
+
注册主题.
|
|
1353
|
+
|
|
1354
|
+
```python
|
|
1355
|
+
@ui.page("/")
|
|
1356
|
+
def page():
|
|
1357
|
+
# 本页范围,所有 rxui.echarts 默认主题均为 walden(最后注册的主题)
|
|
1358
|
+
rxui.echarts.register_theme(
|
|
1359
|
+
"my_theme", Path(__file__).parent / "echarts_theme.json"
|
|
1360
|
+
).register_theme("walden", Path(__file__).parent / "echarts_walden.json")
|
|
1361
|
+
|
|
1362
|
+
opts = {
|
|
1363
|
+
"xAxis": {"data": ["Shirts", "Cardigans"]},
|
|
1364
|
+
"yAxis": {},
|
|
1365
|
+
"series": [{"type": "bar", "data": [5, 20]}],
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
# 主题为 walden
|
|
1369
|
+
rxui.echarts(opts)
|
|
1370
|
+
|
|
1371
|
+
# 主题为 my_theme
|
|
1372
|
+
rxui.echarts(
|
|
1373
|
+
opts,
|
|
1374
|
+
theme="my_theme",
|
|
1375
|
+
)
|
|
1376
|
+
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1349
1379
|
---
|
|
1350
1380
|
|
|
1351
1381
|
#### tab_panels
|
|
@@ -75,8 +75,8 @@ ex4nicegui/reactive/base.py,sha256=CQmWhrKHNMF2ql7O6VOKEOBdEcc3-yagOcERpnUPYus,1
|
|
|
75
75
|
ex4nicegui/reactive/deferredTask.py,sha256=g78TTG1EIkBxjPih01xmrCZw9OxQG93veSVSELWKfcU,987
|
|
76
76
|
ex4nicegui/reactive/dropZone/dropZone.js,sha256=7rSpFJX-Fk_W_NGZhOTyuEw0bzR-YUc8ZYPzQG9KzE0,2713
|
|
77
77
|
ex4nicegui/reactive/dropZone/dropZone.py,sha256=hg9UKTayff8v8Ek-n38h_3wX1Qmiotvdyv1Hsqilh5Y,2590
|
|
78
|
-
ex4nicegui/reactive/EChartsComponent/ECharts.js,sha256=
|
|
79
|
-
ex4nicegui/reactive/EChartsComponent/ECharts.py,sha256=
|
|
78
|
+
ex4nicegui/reactive/EChartsComponent/ECharts.js,sha256=Dhsfzlio9zO2T3LhK5cI7IdPXHtWhbBXMdlL3uvkU24,4110
|
|
79
|
+
ex4nicegui/reactive/EChartsComponent/ECharts.py,sha256=NjJocWIEF4xzvRQVbkTQSaB2fF_GIVf2_QaMKjln9hU,4359
|
|
80
80
|
ex4nicegui/reactive/EChartsComponent/events.py,sha256=ln10cNw5ODiSmdKVi6KBZ6JMR3YIZ6itYZcMgNAlKhA,741
|
|
81
81
|
ex4nicegui/reactive/EChartsComponent/types.py,sha256=_7AekG0IyzRpDEBZMtKRiZ3o3dUCcn6btegBk8c9Fig,1001
|
|
82
82
|
ex4nicegui/reactive/EChartsComponent/utils.py,sha256=YqxodbGD_lk_Bp-K8s8XvgqSXRf_CIHmzeubrqFRuVM,1013
|
|
@@ -105,7 +105,7 @@ ex4nicegui/reactive/officials/column.py,sha256=fllKknMEUw7uNhmP7w4pgBT7HTDbpkN-d
|
|
|
105
105
|
ex4nicegui/reactive/officials/date.py,sha256=lRiJNrgs_oNo9AZTfTX_66dYL7az4co5rfRyIzvGAIo,2440
|
|
106
106
|
ex4nicegui/reactive/officials/dialog.py,sha256=3dyrvsUwM1Q7jr_PgLKt92KDA6Hris0DH90-sKamfFE,1297
|
|
107
107
|
ex4nicegui/reactive/officials/drawer.py,sha256=_Ro6stOh8U3igYMeDwI4omBgi1nld5berrAk9Dv5RVw,2346
|
|
108
|
-
ex4nicegui/reactive/officials/echarts.py,sha256=
|
|
108
|
+
ex4nicegui/reactive/officials/echarts.py,sha256=ANI74NjGFLF7LoABbc8x9L2Z5nLOguptoK4iUIoSizY,12288
|
|
109
109
|
ex4nicegui/reactive/officials/element.py,sha256=-qsHcxfF3fMfU0sJlKtTksX_wYPMIPJ_AgFcZbbI754,412
|
|
110
110
|
ex4nicegui/reactive/officials/expansion.py,sha256=8xwJa0SpsVhFxbYwYRZtf1ul9m4oYTjgmtrRI_lqF_0,1822
|
|
111
111
|
ex4nicegui/reactive/officials/grid.py,sha256=0vLLJOe7t_b351TsYOWpnrPsWKaqV_bG_010Xp-_BfY,2012
|
|
@@ -186,7 +186,7 @@ ex4nicegui/utils/scheduler.py,sha256=1gyq7Y2BkbwmPK_Q9kpRpc1MOC9H7xcpxuix-RZhN9k
|
|
|
186
186
|
ex4nicegui/utils/signals.py,sha256=Jz0jKFPrJIRV0Gye62Bgk2kGgod1KBvDhnF-W3lRm04,7373
|
|
187
187
|
ex4nicegui/utils/types.py,sha256=pE5WOSbcTHxaAhnT24FaZEd1B2Z_lTcsd46w0OKiMyc,359
|
|
188
188
|
ex4nicegui/version.py,sha256=NE7u1piESstg3xCtf5hhV4iedGs2qJQw9SiC3ZSpiio,90
|
|
189
|
-
ex4nicegui-0.8.
|
|
190
|
-
ex4nicegui-0.8.
|
|
191
|
-
ex4nicegui-0.8.
|
|
192
|
-
ex4nicegui-0.8.
|
|
189
|
+
ex4nicegui-0.8.7.dist-info/LICENSE,sha256=0KDDElS2dl-HIsWvbpy8ywbLzJMBFzXLev57LnMIZXs,1094
|
|
190
|
+
ex4nicegui-0.8.7.dist-info/METADATA,sha256=FKLsKPR5EJZnSGTitaJi8RpitJ1XbTfyosp_F8_JL3Y,46832
|
|
191
|
+
ex4nicegui-0.8.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
192
|
+
ex4nicegui-0.8.7.dist-info/RECORD,,
|
|
File without changes
|