Skip to content

Slicer -- min and max issues (Need indexes?) #80

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

Closed
TahiriNadia opened this issue Apr 8, 2019 · 4 comments
Closed

Slicer -- min and max issues (Need indexes?) #80

TahiriNadia opened this issue Apr 8, 2019 · 4 comments

Comments

@TahiriNadia
Copy link
Contributor

In Python version:

Code:

import dash_core_components as dcc

dcc.RangeSlider(
    marks={i: 'Label {}'.format(i) for i in range(-5, 7)},
    min=-5,
    max=6,
    value=[-3, 4]
)

Result:

Screen Shot 2019-04-08 at 1 36 48 PM

In R version:

Code:

library(dashCoreComponents)

dccRangeSlider(
    marks=c(paste("Label", -5:6)),
    min=-5,
    max=6,
    value=list(-3, 4)
)

Result:

Screen Shot 2019-04-08 at 1 37 07 PM

@alexcjohnson
Copy link
Collaborator

c(paste("Label", -5:6)) doesn't look like the R equivalent of
{i: 'Label {}'.format(i) for i in range(-5, 7)}

I think you need something like list('-5'='label -5', '-4'='label -4', ...) instead. Perhaps:
setNames(c(paste("Label", -5:6)), -5:6)?

@alexcjohnson
Copy link
Collaborator

That said the fact that we'll render labels beyond the range of the slider seems like a bug - @TahiriNadia would you mind making an issue for this over at https://github.com/plotly/dash-core-components/issues?

@rpkyle
Copy link
Contributor

rpkyle commented Apr 9, 2019

c(paste("Label", -5:6)) doesn't look like the R equivalent of
{i: 'Label {}'.format(i) for i in range(-5, 7)}

I think you need something like list('-5'='label -5', '-4'='label -4', ...) instead. Perhaps:
setNames(c(paste("Label", -5:6)), -5:6)?

Nice! The latter snippet worked for me.

@TahiriNadia As @alexcjohnson noted, the label rendering problem is a dash-core-components problem rather than something to fix in DashR, but we should open an issue for this there anyway.

If this resolves your problem, feel free to close the issue 🙂

@TahiriNadia
Copy link
Contributor Author

Thank you @alexcjohnson for your ideas. I tried and gave some modifications to convert into a list, here my code:

Code:

dccRangeSlider(
    marks=as.list(setNames(c(paste("Label", -5:6)), -5:6)),
    min=-5,
    max=6,
    value=list(-3, 4)
)

Result:

Screen Shot 2019-04-10 at 10 28 23 AM

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

3 participants