Code Monkey home page Code Monkey logo

Comments (3)

wahlatlas avatar wahlatlas commented on July 20, 2024

Yes, it is (basically your syntax, maybe naming the variable "slider" is an issue?). This works for me:

var mySlider = d3.slider()
.min(0)
.max(10)
.value(7)
.on("slide", function(evt, value) {
    doSomething(value)
}); 

d3.select("#div-where-the-slider-will-be-attached-to")
.call(mySlider);

mySlider.value(newValue);

Do you work with the latest version of the slider? This functionality became available on 29 Sep 2014 through bb33d87

from d3-slider.

VD17593 avatar VD17593 commented on July 20, 2024

I experienced also a problem with the getter/setter function for the value.
When the value is not changed at creation (as in the example above), or when the value is set to 0, the setter doesn't work.
The problem (I think) in the code below is that the condition if (value) { will return false if the value is zero.

slider.value = function(_) {
  if (!arguments.length) return value;
  if (value) {
    moveHandle(stepValue(_));
  };
  value = _;
  return slider;
};

Therefore I would suggest to use another condition like:

if (typeof value !== 'undefined') {

or

if (value>=0) {

Regards.
Nice plugin by the way.

from d3-slider.

citrusvanilla avatar citrusvanilla commented on July 20, 2024

man thank the lord i found this @VD17593 thanks for the spot.. confirmed same behavior for me trying to set a value to something other than zero... new to JS so a rude way to find out that 0 == false

from d3-slider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.