Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Feb 9, 2024
1 parent e92fd74 commit 499f417
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,31 @@ pip install git+https://github.com/eodaGmbH/py-shiny-echarts

```python
from echarts4py.chart import Chart, InitOptions
from echarts4py.options import ChartOption
from echarts4py.options import Line
from echarts4py.renderer import ChartRenderer
from pandas import DataFrame

# Must always be imported, otherwise App is not found
from shiny.express import ui

options = InitOptions(width=600, height=400, renderer="canvas")
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"],
)


lines = ChartOption(
tooltip={"trigger": "axis"},
legend={},
series=[
{"name": "L1", "type": "line", "encode": {"x": 0, "y": 1}},
{"name": "L2", "type": "line", "encode": {"x": 0, "y": 2}},
{"name": "L3", "type": "line", "encode": {"x": 0, "y": 3}},
],
lines = (
Line(x="a", y="b", tooltip=dict(trigger="axis"), legend=dict())
.add_series("c")
.add_series("d")
)


@ChartRenderer
def render_dataset():
return Chart(options, data=data).set_option(lines)
return Chart(init_options, data=data).set_option(lines)
```

```bash
Expand Down
18 changes: 7 additions & 11 deletions docs/examples/getting_started/basic_usage.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
from echarts4py.chart import Chart, InitOptions
from echarts4py.option import ChartOption
from echarts4py.options import Line
from echarts4py.renderer import ChartRenderer
from pandas import DataFrame

# Must always be imported, otherwise App is not found
from shiny.express import ui

options = InitOptions(width=600, height=400, renderer="canvas")
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"],
)


lines = ChartOption(
tooltip={"trigger": "axis"},
legend={},
series=[
{"name": "L1", "type": "line", "encode": {"x": "a", "y": "b"}},
{"name": "L2", "type": "line", "encode": {"x": "a", "y": "d"}},
{"name": "L3", "type": "line", "encode": {"x": 0, "y": "c"}},
],
lines = (
Line(x="a", y="b", tooltip=dict(trigger="axis"), legend=dict())
.add_series("c")
.add_series("d")
)


@ChartRenderer
def render_dataset():
return Chart(options, data=data).set_option(lines)
return Chart(init_options, data=data).set_option(lines)

0 comments on commit 499f417

Please sign in to comment.