Overview
TheScrollbar class creates a control that allows range selection, commonly used for zooming chart axes or scrolling through large datasets. It features draggable grips and a thumb for intuitive interaction.
Constructor
The root element of the chart
Configuration settings for the scrollbar
Settings
Orientation
Orientation of the scrollbar.
Range Settings
Relative start of the selected range, where 0 is the beginning and 1 is the end.
Relative end of the selected range, where 0 is the beginning and 1 is the end.
Animation Settings
Number of milliseconds to play scroll animations for.
Easing function to use for animations.
Properties
thumb
The thumb element - a draggable rectangle between the grips used for panning the selection.
startGrip
Start grip button for adjusting the start of the range.
endGrip
End grip button for adjusting the end of the range.
Methods
updateGrips()
Updates the grip positions based on the currentstart and end values.
start or end changes.
Events
rangechanged
Fired when the range selection changes.New start position (0-1)
New end position (0-1)
Which grip is being dragged, if any
released
Fired when the user releases a grip or thumb after dragging.Examples
Basic Horizontal Scrollbar
Vertical Scrollbar
Scrollbar with Custom Styling
Scrollbar with Animation
Scrollbar with Event Handling
Scrollbar on XY Chart
Programmatically Setting Range
Custom Background
Interaction Modes
The scrollbar supports three interaction modes:1. Grip Dragging
Drag the start or end grip to adjust one side of the range while keeping the other fixed.2. Thumb Dragging
Drag the thumb (area between grips) to pan the entire range without changing its size.3. Background Clicking
Click on the background to center the thumb at that position, maintaining the current range size.4. Double-Click Reset
Double-click the thumb to reset the range to full (0-1).Accessibility
The scrollbar grips include ARIA attributes:ariaLabel- Descriptive label (“From X” / “To Y”)ariaValueNow- Current value as percentageariaValueText- Text representation of valueariaValueMin- Minimum value (“0”)ariaValueMax- Maximum value (“100”)
Theme Tags
The scrollbar automatically receives theme tags based on its orientation:"scrollbar""horizontal"or"vertical"
"main","background"- Background"thumb", orientation - Thumb"resize","button", orientation - Grips"icon"- Grip icons