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

Year slider displays area in between steps #183

Open
Abhi-ak opened this issue May 13, 2021 · 4 comments
Open

Year slider displays area in between steps #183

Abhi-ak opened this issue May 13, 2021 · 4 comments

Comments

@Abhi-ak
Copy link

Abhi-ak commented May 13, 2021

I'm trying to create a year step slider in d3 (v5) with the years 2000 through 2021.
const slider = sliderBottom() .min(new Date(2000, 1, 1)) .max(new Date(2020, 1, 1)) .tickFormat(d3.timeFormat('%Y')) .tickValues(ar) .default(new Date(2000, 10, 3)) .width(rectWidth - margin.right - 65) .height(75) .on("onchange", (value) => { year = d3.timeFormat('%Y')(value); })

const g = d3 .select("#slider") .append('svg') .attr('width', rectWidth - margin.right - 65) .attr('height', 75) .append('g') .attr('transform', 'translate(20,20)')

The slider that is displayed however seems to enable the area in between the "steps" and the year also seems to move along.

  1. Is there a way to have only the exact points at the steps enabled?
  2. How to make the slider responsive ?

yCee4

@johnwalley

@Abhi-ak
Copy link
Author

Abhi-ak commented May 17, 2021

Can anyone help me out here?

@johnwalley
Copy link
Owner

Hi @Abhi-ak. Sorry for not getting back to you sooner. You could try to use the marks method which will restrict the values the slider is allowed to snap to.

Making SVGs responsive is a big topic. For this library you can see an example of dynamically changing the width at

export const Transition = () => {
.

@Abhi-ak
Copy link
Author

Abhi-ak commented May 17, 2021

Hi @johnwalley. Tried giving marks but now the issue is that I cannot select odd years.

Marks: [2000, 2002, 2004, 2006......2022]

@johnwalley
Copy link
Owner

Do you an example somewhere I can test, for example on Codepen? I can't test this at the moment but I just wanted to check that you've tried setting tickValues to [2000, 2002, 2004, ...] and marks to [2000, 2001, 2002, ...]?

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