Comments (3)
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.
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.
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)
- how to set the slider value after initialization? HOT 4
- d3 axis scales
- How to get the value for slider with min, max and step values
- Not work correctly with dates
- Vertical slider has tick values the wrong way HOT 5
- Range Slider: ReferenceError: Can't find variable: divRange HOT 1
- Setting handles of a range slider programatically doesn't work
- Slider causes dropdowns to break HOT 1
- should dispatch "slideend" on click HOT 1
- when two range sliders are on the same page id #handle-one and #handle-two are not unique. HOT 1
- How to make non selected part grey out HOT 1
- Update value from 0 doesn't move the handle
- handle id "handle-one" duplication
- d3-slider with Require.js HOT 1
- d3.rebind has been deprecated. HOT 5
- Need help in ordinal scale. The given code does not work if changed the values HOT 1
- Get the name of the div that the slider is contained in onClick
- This no longer works because d3.rebind has not been a function since d3v4 was launched HOT 1
- After changing min, max, scales do not refresh
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-slider.