Skip to main content
100%

D3.js Round Slider

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Mar 23, 2019
Created on Mar 23, 2019

This example shows a round slider built with D3.js, where a draggable handle moves along a circular track to represent a value. The visualization renders an SVG circle as the slider’s circumference and a small draggable dot that users can click and pull around the ring. The code uses D3’s `d3.drag` and `d3.event` to handle pointer interactions, calculating the handle’s position via trigonometric functions (`Math.acos`, `Math.sin`, `Math.cos`) based on its distance from the center. The slider’s state is stored in a simple data array, and the handle’s color changes from steelblue to red while dragging, as defined in the accompanying CSS.

AI-generated description

Normally, HTML provides traditional sliders with linear shape such as the Input Range Object. This example shows how to create a round slider using D3.js.

forked from <a href='http://bl.ocks.org/fabiovalse/'>fabiovalse</a>'s block: <a href='http://bl.ocks.org/fabiovalse/cd03939330a24f0fbd12'>Round slider</a>

mit Licensed

Similar vizzes