Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG-Styling table cells are not working #1279

Closed
gorkemalgan opened this issue May 12, 2024 · 3 comments
Closed

BUG-Styling table cells are not working #1279

gorkemalgan opened this issue May 12, 2024 · 3 comments
Assignees
Labels
📄 Documentation Internal or public documentation 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem.

Comments

@gorkemalgan
Copy link

Description
I want to set the color of each cell in the table. As I see setting color for entire rows is straightforward and works as expected.
However, styling table cells with style[column_name] is not working. I confirm that all 5 arguments are passed correctly to cell_style, however, in the end table cells are not colored.

Plus, it is not clear how to set colors for different cells for different columns separately? I could not find any explanations in the docs either. Do we need to create a separate style[column_name] function for each column? This is not practical. Can't we just provide a function that is being called for each cell with row_num and column_num?

How to reproduce

import taipy.gui as tg

x_range = range(-10, 11, 4)
data = {
    "x": x_range,
    "y1": [x * x for x in x_range],
    "y2": [100 - x * x for x in x_range],
}

# Code block for coloring cells separately, which does not work
def cell_style(state, value, index, row, column_name):
    if index % 2:
        return "blue-cell"
    else:
        return "red-cell"
tg.Gui(page=tg.Markdown("<|{data}|table|style[y1]=cell_style|>")).run(port=5001)


# # Code block for coloring whole rows, which works as expected
# def even_odd_style(_1, index, _2):
#     if index % 2:
#         return "blue-cell"
#     else:
#         return "red-cell"
# tg.Gui(page=tg.Markdown("<|{data}|table|style=even_odd_style|>")).run(port=5001)

.css file that holds color info

.blue-cell>td {
    color: white;
    background-color: blue;
}
.red-cell>td {
    color: yellow;
    background-color: red;
}

Expected behavior
Coloring cells in the y1 color of the table

Screenshots
When I run coloring for whole rows (commented code block in the above code)
Screenshot 2024-05-12 at 15 17 36

When I run coloring for cells seperately
Screenshot 2024-05-12 at 15 17 20

Runtime environment
Please specify relevant indications.

  • Taipy version: 3.1.1
  • OS: MacOS
  • Browser: Chrome
@gorkemalgan gorkemalgan added the 💥Malfunction Addresses an identified problem. label May 12, 2024
@FredLL-Avaiga
Copy link
Member

you need to remove the >td part of your css declaration

@gorkemalgan
Copy link
Author

you need to remove the >td part of your css declaration

removing it does not fix the problem either

@FlorianJacta
Copy link
Member

image

Removing the td fixed the issue for me.

.blue-cell {
    color: white;
    background-color: blue;
}
.red-cell {
    color: yellow;
    background-color: red;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📄 Documentation Internal or public documentation 🖰 GUI Related to GUI 💥Malfunction Addresses an identified problem.
Projects
None yet
Development

No branches or pull requests

3 participants