Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Feb 20, 2024
1 parent c35a647 commit 09679b3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion shinyecharts/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def snake_to_camel_case(snake_str: str) -> str:


def df_to_dataset(df: DataFrame = None) -> dict:
return {"dataset": {"source": [df.columns.to_list()] + df.to_numpy().tolist()}}
return dict(dataset=dict(source=df.to_dict(orient="list")))
# return {"dataset": {"source": [df.columns.to_list()] + df.to_numpy().tolist()}}


def df_to_pie_data(df: DataFrame, name: str, value: str) -> list:
Expand Down
9 changes: 7 additions & 2 deletions shinyecharts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ def get_options(self) -> dict:

# Set option attributes
def attr(self, **kwargs) -> Chart:
pass
self._option.update(**kwargs)
return self

# TODO: Set data here
def set_data(self, data: DataFrame | dict) -> Chart:
pass
# self._data = (
# df_to_dataset(self._data) if isinstance(self._data, DataFrame) else dict()
# )
self._data = data
return self

def set_option(self, option: dict | ChartOption | BaseOption) -> Chart:
self._option = option if isinstance(option, dict) else option.to_dict()
Expand Down
1 change: 1 addition & 0 deletions shinyecharts/express.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def x_axis(self, type: str = "value", **kwargs) -> Chart:
def y_axis(self):
return self

# TODO: Rename to series_options!? But which method will then add the series?
def series(self, type: SeriesType | str, **kwargs) -> Chart:
type = SeriesType(type).value
if type == "bar":
Expand Down

0 comments on commit 09679b3

Please sign in to comment.