diff --git a/taipy/gui/utils/chart_config_builder.py b/taipy/gui/utils/chart_config_builder.py index 6f557093e3..fd064ae22d 100644 --- a/taipy/gui/utils/chart_config_builder.py +++ b/taipy/gui/utils/chart_config_builder.py @@ -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") diff --git a/tests/gui/builder/control/test_chart.py b/tests/gui/builder/control/test_chart.py index 1fac16c356..c0d650c99f 100644 --- a/tests/gui/builder/control/test_chart.py +++ b/tests/gui/builder/control/test_chart.py @@ -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 = [ + "