diff --git a/README.md b/README.md index 9b60b93..3a75b46 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ 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]], @@ -32,20 +32,16 @@ data = DataFrame( ) -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 diff --git a/docs/examples/getting_started/basic_usage.py b/docs/examples/getting_started/basic_usage.py index 2bae781..6d79412 100644 --- a/docs/examples/getting_started/basic_usage.py +++ b/docs/examples/getting_started/basic_usage.py @@ -1,12 +1,12 @@ 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]], @@ -14,17 +14,13 @@ ) -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)