RangeSelector

The RangeSelector is a widget that allows a user to select a range of values on a scale.

Included in: dx.viz.js, dx.viz-web.js, dx.all.js
Export: default
RangeSelector interactive configuration
Copy Code
Copy to Codepen
$("#rangeselector").dxRangeSelector({
});

                    

This widget represents a scale (numeric or date-time) and two sliders. A user selects the required range by moving the sliders.

RangeSelector

You can create the widget using one of the following approaches.

jQuery
JavaScript
HTML
$(function() {
    $("#rangeSelector").dxRangeSelector({
        scale: {
            startValue: new Date(2011, 0, 1),
            endValue: new Date(2011, 5, 1),
            tickInterval: { days: 7 }
        }
    });
});
<div id="rangeSelector"></div>
Angular
HTML
TypeScript
<dx-range-selector>
    <dxo-scale
        [startValue]="startDate"
        [endValue]="endDate">
        <dxo-tick-interval [days]="7"></dxo-tick-interval>
    </dxo-scale>
</dx-range-selector>
export class AppComponent {
    startDate = new Date(2011, 0, 1);
    endDate = new Date(2011, 5, 1);
}
AngularJS
HTML
JavaScript
<div ng-controller="DemoController">
    <div dx-range-selector="{
        scale: {
            startValue: startDate,
            endValue: endDate,
            tickInterval: { days: 7 }
        }
    }"></div>
</div>
angular.module('DemoApp', ['dx'])
    .controller("DemoController", function ($scope) {
        $scope.startDate = new Date(2011, 0, 1);
        $scope.endDate = new Date(2011, 5, 1);
    });
Knockout
HTML
<div data-bind="dxRangeSelector: {
    scale: {
        startValue: new Date(2011, 0, 1),
        endValue: new Date(2011, 5, 1),
        tickInterval: { days: 7 }
    }
}"></div>
ASP.NET MVC Controls
Razor C#
Razor VB
@(Html.DevExtreme().RangeSelector()
    .ID("rangeSelector")
    .Scale(scale => scale
        .StartValue(new DateTime(2011, 1, 1))
        .EndValue(new DateTime(2011, 6, 1))
        .TickInterval(ti => ti.Days(7))
    )
)
@(Html.DevExtreme().RangeSelector() _
    .ID("rangeSelector") _
    .Scale(Sub(scale)
        scale.StartValue(New DateTime(2011, 1, 1)) _
                .EndValue(New DateTime(2011, 6, 1)) _
                .TickInterval(Sub(ti) ti.Days(7))
    End Sub)
)

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

A chart can be displayed in the background of the RangeSelector widget. This allows end users to select the required range in a chart series. You can also integrate the RangeSelector widget with a stand-alone Chart widget to emulate chart zooming and scrolling.

View Demo Watch Video

See Also

Configuration

An object that defines configuration options for the RangeSelector widget.

Name Description
background

Specifies the options for the range selector's background.

behavior

Specifies the RangeSelector's behavior options.

chart

Specifies the options required to display a chart as the range selector's background.

containerBackgroundColor

Specifies the color of the parent page element.

dataSource

Specifies a data source for the scale values and for the chart at the background.

dataSourceField

Specifies the data source field that provides data for the scale.

elementAttr

Specifies the attributes to be attached to the widget's root element.

export

Configures the exporting and printing features.

indent

Range selector's indent options.

loadingIndicator

Configures the loading indicator.

margin

Generates space around the widget.

onDisposing

A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

onDrawn

A handler for the drawn event.

onExported

A handler for the exported event.

onExporting

A handler for the exporting event.

onFileSaving

A handler for the fileSaving event.

onIncidentOccurred

A handler for the incidentOccurred event.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

onOptionChanged

A handler for the optionChanged event. Executed after an option of the widget is changed.

onValueChanged

A handler for the valueChanged event.

pathModified

Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path.

redrawOnResize

Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates.

rtlEnabled

Specifies whether or not the widget supports right-to-left representation.

scale

Specifies options of the range selector's scale.

selectedRangeColor

Specifies the color of the selected range.

shutter

Specifies range selector shutter options.

size

Specifies the size of the widget in pixels.

sliderHandle

Specifies the appearance of the range selector's slider handles.

sliderMarker

Defines the options of the range selector slider markers.

theme

Sets the name of the theme to be used in the widget.

title

Specifies the widget title.

value

The selected range, initial or current.

Methods

This section describes the methods that can be used in code to manipulate objects related to the RangeSelector.

Name Description
beginUpdate()

Prevents the widget from refreshing until the endUpdate() method is called.

element()

Gets the root element of the widget.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

exportTo(fileName, format)

Exports the widget into a document with a specified name and format.

getDataSource()

Returns the DataSource instance.

getSize()

Gets the current size of the widget.

getValue()

Gets the currently selected range.

hideLoadingIndicator()

Conceals the loading indicator.

instance()

Returns this widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from the specified event.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

on(eventName, eventHandler)

Subscribes to a specified event.

on(events)

Subscribes to the specified events.

option()

Gets the widget's options.

option(optionName)

Gets a specific option value.

option(optionName, optionValue)

Assigns a new value to a specific option.

option(options)

Sets one or more options.

print()

Opens the browser's print window.

render()

Redraws the widget.

render(skipChartAnimation)

Redraws a widget.

setValue(value)

Selects a specific range.

showLoadingIndicator()

Displays the loading indicator.

svg()

Returns the widget's SVG markup.

Events

This section describes events fired by this widget.

Name Description
disposing

Raised when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only.

drawn

Fires when the widget has finished drawing itself.

exported

Fires after data from the widget is exported.

exporting

Fires before data from the widget is exported.

fileSaving

Fires before a file with exported data is saved on the user's local storage.

incidentOccurred

Fires when an error or warning appears in a widget.

initialized

Raised only once, after the widget is initialized.

optionChanged

Raised after an option of the widget is changed.

valueChanged

Fires when the selected range is changed.

See Also