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

Add more than two sliders will not update the value #124

Open
isjwtang opened this issue May 2, 2020 · 1 comment
Open

Add more than two sliders will not update the value #124

isjwtang opened this issue May 2, 2020 · 1 comment
Assignees
Labels

Comments

@isjwtang
Copy link

isjwtang commented May 2, 2020

Thanks for this great plugin.
I don't know if it's a bug or just the normal behavior but it's possible to update the values of all sliders if users add more than two sliders.
I want to add more than two sliders on the axis, I add more than two default value like this slider.default([0.01, 0.011, 0.015]) . Through this code I can get 3 sliders in the webpage, but when I slide the slider, only the first two sliders update the value, the latter does not update the value.
I have read the source code, and I found that it only judged the value of the first two sliders
here: updateValue().
Therefore, only when the first two sliders are updated will trigger the ‘onchange event’ and update the value.

My code here ( Modified from the example range):

var data = [0, 0.005, 0.01, 0.015, 0.02, 0.025];
  // Range
  var sliderRange = d3
    .sliderBottom()
    .min(d3.min(data))
    .max(d3.max(data))
    .width(300)
    .tickFormat(d3.format('.2%'))
    .ticks(5)
    .default([0.01, 0.011, 0.015])
    //.fill('#2196f3')
    .on('onchange', val => {
        console.log(val);
      d3.select('p#value-range').text(val.map(d3.format('.2%')).join('-'));
    });

When I change the function ’updateValue()‘ like this, it works:

 function updateValue(newValue, notifyListener) {
    if (
        JSON.stringify(value) !== JSON.stringify(newValue)
    ) 

Thanks again for your great plugin.

@johnwalley
Copy link
Owner

Hi @jynwhey. I'm afraid it is intended behaviour. I'll take a look at what it would take to generalise to more than two handles when I next get the chance but it won't be for a week or two.

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

No branches or pull requests

2 participants