-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stefan Kuethe
committed
Feb 14, 2024
1 parent
34bedf9
commit 1de63bd
Showing
7 changed files
with
115 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pandas import DataFrame | ||
from shiny.express import ui | ||
from shinyecharts.express import Chart, InitOptions | ||
from shinyecharts.renderer import ChartRenderer | ||
|
||
init_options = InitOptions(width=600, height=400, renderer="canvas") | ||
|
||
data = DataFrame( | ||
[[0, 1, 2, 3], [1, 4, 5, 6], [2, -2, 4, 9]], | ||
columns=["a", "b", "c", "d"], | ||
) | ||
|
||
|
||
@ChartRenderer | ||
def render_lines(): | ||
return Chart().data(data).encode("a", "b").encode("a", "c", color="pink") | ||
|
||
|
||
@ChartRenderer | ||
def render_scatter(): | ||
return Chart().data(data).encode("a", "b", type="scatter") | ||
|
||
|
||
@ChartRenderer | ||
def render_bar(): | ||
return Chart().data(data).encode("a", "b", type="bar").encode("a", "c", type="bar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://shinylive.io/py/editor/#code=NobwRAdghgtgpmAXGKAHVA6VBPMAaMAYwHsIAXOcpMAMwCdiYACVKCAEygGcmBLGVMTpkmAEShkoAMTqw4AHQiKAxEwCyAVy4ioAGwDuUbDwBGcPgKEV2eJsTIALOHX28u5gILo+PCPaY0xBocivSMTFwOvBDYGHAAHqh0cFw8-ILCTBq8oQzMkdHYcIQOUMJplpkAwqXCtgCSELxkAPKoZLykXLnhBTHFtWRcGMTtnRAVGSIAMtEKEGH5Uf0lZUMYyRzOzhZTTDVrAEqU7Nt0iorRzQD6ox1dTAC8TI3NbfcTABSu7I6PAGwABkBticvAA5g4yI8ACzA2ybU7JOiPeRENgAN24aIAlBcOBIoE8xISZHJPoomFSmMBgCCmABGWwAJlsAGYALq2YBMpgw2wAVls-y5NNZTAAtOL+UwAJwcrmU6kkXQaGATR7ANFQNG2NEmXVMNGEQ1o9hoxUQPFKG26OY8Z4UiDUpizCBwT7xVEoQ3Yb0G-BMMjEYi6DqoR7sXiEMifMh0CHg5zeqDxNy42y6OBJjiR6OxnHWl0YKDsdjXdwJlIUoi4pVUktlivOXjVs11q34xQAAQOwmOW2RilONCYiOc104kncBcQ9bHcDIGjozr7sauZFuYy6tinUEjhJxGBnW4+nzt7q41rAAF88OBoPBqMkAI7ZZLwcjDMjxMj4IikBQVDIH0RSrOUt4ckAA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class ChartContext(object): | ||
def __init__(self, id): | ||
self.id = id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pandas import DataFrame | ||
from shinyecharts.express import Chart | ||
|
||
|
||
def test_chart(): | ||
# Prepare | ||
data = DataFrame([[1, 2], [2, 4]], columns=["x", "y"]) | ||
|
||
# Act | ||
chart = Chart().dark().data(data).encode("x", "y") | ||
print(chart._option) | ||
print(chart.to_dict()) | ||
|
||
chart_dict = chart.to_dict() | ||
|
||
# Assert | ||
assert chart_dict["theme"] == "dark" |