Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

BUG-Passing a function which returns a dictionary to chart.properties does not always work #897

Closed
arcanaxion opened this issue Aug 28, 2023 · 1 comment
Assignees
Labels
Gui: Back-End Related to the back-end side of Taipy GUI. 💥Malfunction Addresses an identified problem. 🟧 Priority: High Stalls work on the project or its dependents

Comments

@arcanaxion
Copy link

Description

Per title, I receive this warning:

Warning 1: chart.properties (tp_TpExPr_create_chart_properties_selected_type_TPMDL_1_0) must be a dict.

How to reproduce

from taipy.gui import Gui, Markdown
import pandas as pd

x_range = range(-10, 11)
df = pd.DataFrame({
    "X": x_range,
    "Y": [x*x for x in x_range],
})

def create_chart_properties(selected_type):
    properties = {
        "x": "X",
        "y": "Y",
        "type": selected_type,
    }
    print(properties)
    return properties

types = ["bar", "line"]
selected_type = types[0]

md = Markdown(
"""
<|{df}|chart|properties={create_chart_properties(selected_type)}|rebuild|>

<|{selected_type}|toggle|lov={types}|>
""")

Gui(md).run()

Steps to reproduce:

  1. Toggle to "line" -- no immediate changes to the chart
  2. Refresh page
    a. Observe that the chart changed to "line"
    b. Also, the warning above is in the terminal
  3. Toggle back to "bar" -- no immediate changes to the chart
  4. Refresh page
    a. Observe that the chart did not change back to "bar"
    b. The warning is printed again

Expected behavior
The chart should switch between "bar" and "line" as the toggle control is toggled.

I guess the need to refresh may be related to Avaiga/taipy#466, but I don't know about the warning. Must the properties property be a literal dictionary and not a function return value, even when used with rebuild?

@arcanaxion arcanaxion added the 💥Malfunction Addresses an identified problem. label Aug 28, 2023
@FabienLelaquais FabienLelaquais added Gui: Back-End Related to the back-end side of Taipy GUI. 🟧 Priority: High Stalls work on the project or its dependents labels Sep 11, 2023
@FredLL-Avaiga
Copy link
Member

as for now, properties don't allow chart rebuild.
I can fix the warning (which is a separate issue) but it won't fix this issue.

@FredLL-Avaiga FredLL-Avaiga self-assigned this Sep 14, 2023
FredLL-Avaiga pushed a commit that referenced this issue Oct 9, 2023
FredLL-Avaiga added a commit that referenced this issue Oct 9, 2023
* #897 properties refresh

* handle complex expressions

* format

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Gui: Back-End Related to the back-end side of Taipy GUI. 💥Malfunction Addresses an identified problem. 🟧 Priority: High Stalls work on the project or its dependents
Projects
None yet
Development

No branches or pull requests

3 participants