Skip to content

[🐛 BUG] Slider labels don't work well with negative and decimal values #2586

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

Open
1 of 6 tasks
enarroied opened this issue Apr 28, 2025 · 2 comments
Open
1 of 6 tasks
Labels
GUI: Front-End 🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 🟧 Priority: High Must be addressed as soon

Comments

@enarroied
Copy link

enarroied commented Apr 28, 2025

🔍 What went wrong?

When using the slider visual element, if I use the labels parameter to customize the displayed values, it works fine if I use the default step (1) as long as I use positive values. it also works well if I use steps over 1.

However, if the step is under 1, it groups all the labels at the location of the unit part of the number (not rounded --> 0.1, 0.3, and 0.7 get grouped under 0).

If the min value specifies a range that goes in the negatives, labels seem to do OK with bounding to the minimum value, but all other negative steps semm to not work (at all, they don't get grouped anywhere).

✅ Expected Behavior

The labels argument should be able to place labels at negative ticks, as well as decimals.
I could imagine problems if someone sets unlikely steps (imagine, 0.65987... but I tried with 1.036 and the steps work good -the labels don't).

🔄 Steps to Reproduce

This code shows several case scerios:

from taipy.gui import Gui
from taipy.gui import builder as tgb

with tgb.Page() as slider_page:
    tgb.text("# Problem with slider labels with some steps", mode="md")

    tgb.text("## With positive natural values, it seems OK", mode="md")
    tgb.slider(
        value="{None}",
        min=0,
        max=4,
        step=1,  # Default
        labels={
            0: "1",
            1: "2",
            2: "3",
            3: "4",
            4: "5",
        },
    )

    tgb.text(
        "## Negative values seem to be problematic, except for lower bound", mode="md"
    )
    tgb.slider(
        value="{None}",
        min=-2,
        max=2,
        step=1,  # Default
        labels={
            -2: "-2",
            -1: "-1",  # This one just disappears, as opposed to deciomal values that get overlapped
            0: "0",
            1: "1",
            2: "2",
        },
    )

    tgb.text("## Decimal steps seem to cause problems:", mode="md")
    tgb.slider(
        value="{None}",
        min=0,
        max=1,
        step=0.1,
        labels={
            0.0: "0",
            0.2: "0.2",
            0.4: "0.4",
            0.6: "0.6",
            0.8: "0.8",
            1.0: "1",
        },
    )

    tgb.text("## Non decimal steps seem to do ok:", mode="md")
    tgb.slider(
        value="{None}",
        min=0,
        max=40,
        step=10,
        labels={
            0: "1",
            10: "2",
            20: "3",
            30: "4",
            40: "5",
        },
    )

    tgb.text("## Let's try a dumb step, just for fun:", mode="md")
    tgb.slider(
        value="{None}",
        min=0,
        max=10,
        step=1.036,  # Default
        labels={
            0: "a",
            1.036: "b",
            2.072: "c",
            4.08: "d",
            5.44: "e",
        },
    )

if __name__ == "__main__":
    gui = Gui(slider_page)
    gui.run(
        title="Slider step problem",
        dark_mode=False,
        use_reloader=True,
    )

🖼️ Screenshots (Optional)

Image

💻 Runtime Environment

Lubuntu 24.04

🌐 Browser (if applicable)

Brave

🖥️ Operating System

Linux

📦 Taipy Version

4.0.2 and 4.0.3

📋 Additional Context (Optional)

📜 Code of Conduct

  • I have checked the existing issues to avoid duplicates.
  • I am willing to work on this issue (optional)

✅ Acceptance Criteria

  • A reproducible unit test is added.
  • Code coverage is at least 90%.
  • The bug reporter validated the fix.
  • Relevant documentation updates or an issue created in
@enarroied
Copy link
Author

Hi!
I wonder if this issue was missed?
I think it's a real concern (may not be a priority, but I'd say it's a bug...)

@FlorianJacta
Copy link
Member

Hi @enarroied this issue has not been missed. We reviewed it last week and will surely review it tomorrow

@jrobinAV jrobinAV added 🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 🟧 Priority: High Must be addressed as soon GUI: Front-End labels May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: Front-End 🖰 GUI Related to GUI 🆘 Help wanted Open to participation from the community 🟧 Priority: High Must be addressed as soon
Projects
None yet
Development

No branches or pull requests

3 participants