Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
15.53k stars 1.87k forks source link

[🐛 BUG] Setting width/height with CSS units not working for metrics #2141

Open FlorianJacta opened 1 month ago

FlorianJacta commented 1 month ago

What went wrong? 🤔

Setting width and height for metrics with CSS units is not working. This won't change the width/height as expected.

This works when just putting a number. It took a while for me to figure out (I went looking at the actual PR).

If this issue could be backported to another patch, this would be great.

Expected Behavior

This should work with all CSS units supported by Taipy. Or the documentation should change to reflect this behavior.

Steps to Reproduce Issue

from taipy.gui import Gui

value = 50

page = """
<|{value}|metric|>

## Works
<|{value}|metric|width=300|height=300|>

## Height not working, Width not working
<|{value}|metric|width=150px|height=300px|>
<|{value}|metric|width=300px|height=300px|>

## Height not working, Width not working
<|{value}|metric|width=150rem|height=150rem|>
<|{value}|metric|width=300rem|height=150rem|>
"""

Gui(page).run()

Screenshots

image

Version of Taipy

4.0

Acceptance Criteria

Code of Conduct

naaa760 commented 1 month ago

Hello @FlorianJacta :)

FlorianJacta commented 1 month ago

I think 150 and 150px are two different units. It is related to this issue too: https://github.com/Avaiga/taipy/issues/2142 so you should also be assigned there

vgauraha62 commented 1 month ago

Parameters in the 'metric' component do not accept units like, px or rem. Use numerical values without units (e.g. width=150, height=300). This should apply the desired dimensions to the metric component.

Yubarajhalder commented 1 month ago

The issue lies in how you're setting the width and height properties in the metric widget.

Taipy GUI uses a specific syntax for styling, and width and height should be defined within a style attribute.

Try modifying your page string as follows:

page = """ <|{value}|metric|style={"width": "300px", "height": "300px"}|> """

Or, for multiple styles:

page = """ <|{value}|metric|style={"width": "300px", "height": "300px", "font-size": "24px"}|> """

This should correctly apply the width and height styles to your metric widget.

Additionally, consider using units like px for pixels or % for percentage-based sizing.

For more information on Taipy GUI styling, refer to the official documentation:

FlorianJacta commented 4 weeks ago

@Yubarajhalder your answer is not answering the issue

github-actions[bot] commented 2 weeks ago

This issue has been labelled as "🥶Waiting for contributor" because it has been inactive for more than 14 days. If you would like to continue working on this issue, please add another comment or create a PR that links to this issue. If a PR has already been created which refers to this issue, then you should explicitly mention this issue in the relevant PR. Otherwise, you will be unassigned in 14 days. For more information please refer to the contributing guidelines.

github-actions[bot] commented 6 hours ago

This issue has been unassigned automatically because it has been marked as "🥶Waiting for contributor" for more than 14 days with no activity.