Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Not a cheeseburger, just a nifty d3 slider. Say adios to buggy Bootstrap sliders and hello to a d3-powered, mobile friendly axis slider. By Dave Johnson and Chris Wilson for TIME Magazine and open-sourced under the MIT license.
npm install d3slider
import slider from 'd3slider';
let mySlider = slider(container, {
domain: [0, 100],
playButton: true,
interval: 1,
tickInterval: 10,
value: 50,
loop: true,
onDrag: function(v){
console.log(v)
/* ... */
}
});
container
is a CSS selector or HTML element that will house the slider, which will create its own div with the class d3slider
and create an svg
object inside.
domain
: The min and max values of the slidesvalue
: Initial slider position. Defaults to first value in domain.onDrag
: The callback that fires when the position of the slider changes.playButton
: Boolean. Whether to include a play button to animate through the sliderloop
: Whether to start over again when you reach the end when animating through with the buttoninterval
: The value positions for the slider along the domain. This will often be 1, but might be 4 for, say, a slider of presidential elections. Leave this undefined if you want floating valuestickInterval
: How often to place a tick and a label on the slider, as a multiple of the number of positions between the minimum and maximum of the domain.playInterval
: How far to advanced when you animate the slider. Defaults to interval
, which defaults to 1
, and falls back on 20 steps if there is no interval
.tickValues
: Specific values for ticksformat
: A function that accepts the value of the tick and returns a labelsnapToTick
: boolean, whether to force user to the nearest tick valuetextBox
: Whether to display the value in the box over the slideronResize(width)
: A function to call if the window size changesonFinish
: A function to call when the tick reaches the endspeed
: Milliseconds between stops on autoplaylocked
: Whether the slider is manipulablesize
: The radius of the thumbnail. Default is 12. Don't make it too small or it will be hard to catch on mobile.color
: Hex color of thumbmargin
: { left: 25, right: 20, top: 20, bottom: 0 }
, e.g. Normally we'll guess the appropriate values based on your other params. Careful messing with this since you can cut off the thumbnail with small values.height
: The current heightwidth
: The current widthaxis
: The d3 axis objectscale
: The d3 scale objectdomain
: The domain as an arraysetValue(value, fire_callback)
: Set the value of the slider. Unless fire_callback === false
, will fire the onDrag
functiongetValue()
: Get the current value of the sliderplaying()
: Whether the slider is currently playingstart(v)
: Start the animation. Optional v
sets the value firststop()
: Stop the animationlock()
: Freeze the sliderunlock()
: Unfreeze the slidersetButtonColor
: Change the color of the thumbnail. Only needed if you want to change according to the value or a behaviorresize()
: Force the resize functionThis module uses Webpack to compile the source into the two files in the dist
directory, which can be included in an HTML file the old-fashion way.
<script src="./dist/d3slider.min.js"></script>
<script>
let mySlider = d3slider({ ... })
</script>
The files dist/d3slider.js
(with comments and source maps) and dist/d3slider.min.js
(minified, much smaller) are always up-to-date. If you make any modifications and need to recompile, just run npm run build
and npm run minify
from the root directory after running npm install
.
If you want to require
or import
the module and compile it as part of a larger project, you do not have to run npm install
. Just include it in your Node environment:
const d3slider = require('d3slider').d3slider;
FAQs
Not a cheeseburger, just a nifty d3 slider.
We found that d3slider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.