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

Allow each value to have a different tooltip formatter #80

Open
ni3k opened this issue Sep 25, 2023 · 2 comments
Open

Allow each value to have a different tooltip formatter #80

ni3k opened this issue Sep 25, 2023 · 2 comments

Comments

@ni3k
Copy link

ni3k commented Sep 25, 2023

We’re using this slider for our project, and you guys did a really great job with it—it’s set up really nicely. Kudos!

But, there’s one thing I’m missing: being able to have different tooltip formats when I put in different values (so each value can be formatted differently). If you think having more tooltip functions is a good idea, I’m ready to help by adding this to the project. To make it clear what I’m missing, I’ll give an example below of how it could be done with options:

                   <Slider
                        ....
                        :options="{
                            connect: [true, true, true],
                            tooltips: [
                                { from: Number, to: (value) => `This is the first value ${value}` },
                                { from: Number, to: () => 'Second value' },
                            ]
                        }"
                       ...
                    ></Slider>

The feature would be particularly useful when you want to add a different name to the tooltip.

The problem with using options is that there is no way to merge the tooltips since the internal tooltip formatter is used in the case of merging.

Proposal: Allow format to be an array of functions (v) => string and use it based on the value's index const tooltipsFormat = v.map((v, idx) => tooltipFormats.value[i])

@ni3k
Copy link
Author

ni3k commented Sep 25, 2023

feel free to assign me to the issue and I'll be back with a MR

@fuxinko
Copy link

fuxinko commented Sep 2, 2024

I managed to handle this in a very hacky way. From format function I returned HTML with 2 span elements, one for each handle and then show and hide them with some weird CSS - https://stackoverflow.com/a/12198561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants