Skip to content

Commit

Permalink
refactor: type
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfu1 committed Dec 21, 2023
1 parent 5ca1c6d commit 70167fa
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 31 deletions.
29 changes: 14 additions & 15 deletions example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"colorField": "genre"
}

charts(options=options, type="Column")
charts(type="Column", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand All @@ -50,7 +50,7 @@
"colorField": "genre"
}
charts(options=options, type="Column")
charts(type="Column", options=options)
```
""")

Expand All @@ -73,7 +73,7 @@
"colorField": "genre"
}

charts(options=options, type="Bar")
charts(type="Bar", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand All @@ -94,7 +94,7 @@
"colorField": "genre"
}
charts(options=options, type="Bar")
charts(type="Bar", options=options)
```
""")

Expand All @@ -113,7 +113,7 @@
"yField": "close"
}

charts(options=options, type="Line")
charts(type="Line", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand All @@ -130,7 +130,7 @@
"yField": "close"
}
charts(options=options, type="Line")
charts(type="Line", options=options)
```
""")

Expand All @@ -149,7 +149,7 @@
"yField": "close"
}

charts(options=options, type="Area")
charts(type="Area", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand All @@ -166,7 +166,7 @@
"yField": "close"
}
charts(options=options, type="Area")
charts(type="Area", options=options)
```
""")

Expand Down Expand Up @@ -206,7 +206,7 @@
"legend": False,
}

charts(options=options, type="Pie")
charts(type="Pie", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand Down Expand Up @@ -244,7 +244,7 @@
"legend": False,
}
charts(options=options, type="Pie")
charts(type="Pie", options=options)
```
""")

Expand Down Expand Up @@ -399,7 +399,7 @@
]
}

charts(options=options, type="DualAxes")
charts(type="DualAxes", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand Down Expand Up @@ -552,12 +552,11 @@
]
}
charts(options=options, type="DualAxes")
charts(type="DualAxes", options=options)
```
""")



"""
## Scatter Chart
"""
Expand All @@ -573,7 +572,7 @@
"shapeField": "point"
}

charts(options=options, type="Scatter")
charts(type="Scatter", options=options)

source = st.expander("Source Code")
source.markdown("""
Expand All @@ -592,6 +591,6 @@
"shapeField": "point"
}
charts(options=options, type="Scatter")
charts(type="Scatter", options=options)
```
""")
2 changes: 1 addition & 1 deletion example/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
streamlit
streamlit-charts==0.1.0
streamlit-charts==0.1.1
11 changes: 5 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
This project was created to allow us to render charts in streamlit, [live demo](https://ant-design-charts.streamlit.app/).

![examples](https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*11uNQrnKdFoAAAAAAAAAAAAADmJ7AQ/original)
![Build Status](https://github.com/ant-design/ant-design-charts/workflows/build/badge.svg)
![npm Version](https://img.shields.io/npm/v/@ant-design/charts)
![npm Download](https://img.shields.io/npm/dm/@ant-design/charts)
[![GitHub stars](https://img.shields.io/github/stars/ant-design/ant-design-charts)](https://github.com/ant-design/ant-design-charts/stargazers)
Expand All @@ -21,7 +20,7 @@ This project was created to allow us to render charts in streamlit, [live demo](
## Installation

```
pip3 install streamlit-charts
pip3 install streamlit-charts
```


Expand Down Expand Up @@ -49,20 +48,20 @@ from streamlit_charts import charts
},
}

charts(options=options, type="Column", key="streamlit-charts")
charts(type="Column", options=options, key="streamlit-charts")
```

<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*aPxqSpQcsUQAAAAAAAAAAAAADmJ7AQ/original" width="640" alt="example">


## API

Now, There is only one API for `streamlit-charts`, named `charts`, see the `options` in [Ant Design Charts](https://ant-design-charts.antgroup.com/).
Now, There is only one API for `streamlit-charts`, named `charts`, see the `type | options` in [Ant Design Charts](https://ant-design-charts.antgroup.com/).

| Property | Description | Type | Default |
| -------- | --------------------------------------------------------------------------------------------------------------- | --------------------- | ------- |
| options | the [options](https://ant-design-charts.antgroup.com/) for the visualization | `Options` \| `null` | - |
| type | the chart type of the charts | `Str` | `Column` |
| type | the chart type of the charts, eg: `Line、Column、Bar、Pie...` | `Str` | `Column` |
| options | the options for the visualization | `Options` | - |


## Development
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def read(*names, **kwargs):

setup(
name="streamlit-charts",
version="0.1.0",
version="0.1.1",
author="lxuf1",
author_email="[email protected]",
description="Render Ant Design Charts in Streamlit",
Expand Down
13 changes: 6 additions & 7 deletions streamlit_charts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@
# `declare_component` and call it done. The wrapper allows us to customize
# our component's API: we can pre-process its input args, post-process its
# output value, and add a docstring for users.
def charts(options, type=None, key=None):
def charts(type, options, key=None):
"""Create a new instance of "charts".
Parameters
----------
type: str
Required. The chart type to be visualized. More type can be found in https://ant-design-charts.antgroup.com/
options: dict
Required. The options/spec of charts to be visualized.
type: str or None
The chart type to be visualized. If this is None, the default type Column will be used.
More type can be found in https://ant-design-charts.antgroup.com/
key: str or None
An optional key that uniquely identifies this component. If this is
None, and the component's arguments are changed, the component will
Expand All @@ -70,8 +69,8 @@ def charts(options, type=None, key=None):
component_value = _component_func(options=options, type=type, key=key)
return component_value

def st_charts(options, type=None, key=None):
return charts(options, type, key=key)
def st_charts(type, options, key=None):
return charts(type, options, key)


# Add some test code to play with the component while it's in development.
Expand Down Expand Up @@ -100,4 +99,4 @@ def st_charts(options, type=None, key=None):
"tooltip": {}
}

charts(options=options, type="Column", key="streamlit-charts")
charts(type="Column", options=options, key="streamlit-charts")
2 changes: 1 addition & 1 deletion streamlit_charts/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "streamlit-charts",
"version": "0.1.0",
"version": "0.1.1",
"private": true,
"scripts": {
"start": "react-scripts start",
Expand Down

0 comments on commit 70167fa

Please sign in to comment.