Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion taipy/gui/utils/chart_config_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __get_col_from_indexed(col_name: str, idx: int) -> t.Optional[str]:
def _build_chart_config( # noqa: C901
gui: "Gui", attributes: t.Dict[str, t.Any], cols_descriptions_list: t.List[t.Dict[str, t.Dict[str, str]]]
):
if "data" not in attributes and "figure" in attributes:
if ("data" not in attributes and "figure" in attributes) or (attributes.get("data") is None):
return {"traces": []}
default_type = attributes.get("_default_type", "scatter")
default_mode = attributes.get("_default_mode", "lines+markers")
Expand Down
18 changes: 18 additions & 0 deletions tests/gui/builder/control/test_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,21 @@ def test_chart_multi_data(gui: Gui, helpers, csvdata):
]
gui._set_frame(inspect.currentframe())
helpers.test_control_builder(gui, page, expected_list)


def test_chart_none_data(gui: Gui, helpers):
data=None # noqa: F841
with tgb.Page(frame=None) as page:
tgb.chart( # type: ignore[attr-defined]
data="{data}",
)
expected_list = [
"<Chart",
"data={_TpD_tpec_TpExPr_data_TPMDL_0}",
'dataVarNames=""',
'defaultConfig="{&quot;traces&quot;: []}"',
'libClassName="taipy-chart"',
'updateVarName="_TpD_tpec_TpExPr_data_TPMDL_0"',
]
gui._set_frame(inspect.currentframe())
helpers.test_control_builder(gui, page, expected_list)
16 changes: 16 additions & 0 deletions tests/gui/control/test_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def test_chart_indexed_properties_with_arrays(gui: Gui, helpers):
]
helpers.test_control_md(gui, md, expected_list)


def test_chart_multi_data(gui: Gui, helpers, csvdata):
md_string = "<|{csvdata}|chart|x=Day|y=Daily hospital occupancy|data[1]={csvdata}|>"
expected_list = [
Expand All @@ -230,3 +231,18 @@ def test_chart_multi_data(gui: Gui, helpers, csvdata):
]
gui._set_frame(inspect.currentframe())
helpers.test_control_md(gui, md_string, expected_list)


def test_chart_none_data(gui: Gui, helpers):
data = None # noqa: F841
md_string = "<|{data}|chart|>"
expected_list = [
"<Chart",
"data={_TpD_tpec_TpExPr_data_TPMDL_0}",
'dataVarNames=""',
'defaultConfig="{&quot;traces&quot;: []}"',
'libClassName="taipy-chart"',
'updateVarName="_TpD_tpec_TpExPr_data_TPMDL_0"',
]
gui._set_frame(inspect.currentframe())
helpers.test_control_md(gui, md_string, expected_list)
Loading