Skip to content
import SizeSlider from "@arcgis/core/widgets/smartMapping/SizeSlider.js";
Inheritance:
SizeSliderSmartMappingSliderBaseWidgetAccessor
Since
ArcGIS Maps SDK for JavaScript 4.12

The SizeSlider widget is intended for authoring and exploring data-driven visualizations in any layer that can be rendered with a SizeVariable. At a minimum you must set the min, max, and stops properties of the widget.

See the image below for a summary of the configurable options available on this slider.

SizeSlider with annotations

The fromRendererResult() method can be used to conveniently create this slider from the result of the createContinuousRenderer() method.

const sizeParams = {
layer: layer,
basemap: map.basemap,
valueExpression: "( $feature.POP_POVERTY / $feature.TOTPOP_CY ) * 100",
view: view
};
let rendererResult = null;
sizeRendererCreator
.createContinuousRenderer(sizeParams)
.then(function(response) {
rendererResult = response;
layer.renderer = response.renderer;
return histogram({
layer: layer,
valueExpression: sizeParams.valueExpression,
view: view,
numBins: 70
});
})
.then(function(histogramResult) {
const sizeSlider = SizeSlider.fromRendererResult(rendererResult, histogramResult);
sizeSlider.container = "slider";
})
.catch(function(error) {
console.log("there was an error: ", error);
});

This slider should be used to update a size visual variable in a layer's renderer. It is the responsibility of the app developer to set up event listeners on that update the size variable of the appropriate renderer.

// when the user slides the handle(s), update the renderer
// with the updated size stops
sizeSlider.on(["thumb-change", "thumb-drag"], function() {
const renderer = layer.renderer.clone();
const sizeVariable = renderer.visualVariables[0];
renderer.visualVariables = [ sizeSlider.updateVisualVariable(sizeVariable) ];
layer.renderer = renderer;
});
See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.
Example
// Typical usage
const slider = new SizeSlider({
container: "sliderDiv",
min: 0,
max: 100,
stops: [
{ value: 0, size: 4 },
{ value: 100, size: 40 }
]
});

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

container

autocast inherited Property
Type
HTMLElement | null | undefined
Inherited from: Widget

The ID or node representing the DOM element containing the widget. This property can only be set once. The following examples are all valid use case when working with widgets.

Examples
// Create the HTML div element programmatically at runtime and set to the widget's container
const basemapGallery = new BasemapGallery({
view: view,
container: document.createElement("div")
});
// Add the widget to the top-right corner of the view
view.ui.add(basemapGallery, {
position: "top-right"
});
// Specify an already-defined HTML div element in the widget's container
const basemapGallery = new BasemapGallery({
view: view,
container: basemapGalleryDiv
});
// Add the widget to the top-right corner of the view
view.ui.add(basemapGallery, {
position: "top-right"
});
// HTML markup
<body>
<div id="viewDiv"></div>
<div id="basemapGalleryDiv"></div>
</body>
// Specify the widget while adding to the view's UI
const basemapGallery = new BasemapGallery({
view: view
});
// Add the widget to the top-right corner of the view
view.ui.add(basemapGallery, {
position: "top-right"
});

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

destroyed

readonlyinherited Property
Type
boolean
Inherited from: Widget

When true, this property indicates whether the widget has been destroyed.

handlesSyncedToPrimary

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.18

Only applicable when three thumbs (i.e. handles) are set on the slider values. This property indicates whether the position of the outside handles are synced with the middle, or primary, handle. When enabled, if the primary handle is moved then the outside handle positions are updated while maintaining a fixed distance from the primary handle.

Only applicable when primaryHandleEnabled is true.

See also
Default value
true
Example
// enables the primary handles and syncs it with the others
slider.primaryHandleEnabled = true;
slider.handlesSyncedToPrimary = true;

histogramConfig

inherited Property
Type
HistogramConfig | null | undefined
Inherited from: SmartMappingSliderBase

The Histogram associated with the data represented on the slider. The bins are typically generated using the histogram statistics function.

See also
Example
histogram({
layer: featureLayer,
field: "fieldName",
numBins: 30
}).then(function(histogramResult){
// set the histogram to the slider
slider.histogramConfig = {
bins: histogramResult.bins
};
});

icon

inherited Property
Type
Icon["icon"] | null | undefined
Inherited from: Widget
Since
ArcGIS Maps SDK for JavaScript 4.27

Icon which represents the widget. It is typically used when the widget is controlled by another one (e.g. in the Expand widget).

See also

id

inherited Property
Type
string
Inherited from: Widget

The unique ID assigned to the widget when the widget is created. If not set by the developer, it will default to the container ID, or if that is not present then it will be automatically generated.

inputFormatFunction

inherited Property
Type
InputFormatFunction | null | undefined
Inherited from: SmartMappingSliderBase
Since
ArcGIS Maps SDK for JavaScript 4.14

A function used to format user inputs. As opposed to labelFormatFunction, which formats thumb labels, the inputFormatFunction formats thumb values in the input element when the user begins to edit them.

The image below demonstrates how slider input values resemble corresponding slider values by default and won't match the formatting set in labelFormatFunction.

Slider without input formatter

If you want to format slider input values so they match thumb labels, you can pass the same function set in labelFormatFunction to inputFormatFunction for consistent formatting.

Slider with input formatter

However, if an inputFormatFunction is specified, you must also write a corresponding inputParseFunction to parse user inputs to understandable slider values. In most cases, if you specify an inputFormatFunction, you should set the labelFormatFunction to the same value for consistency between labels and inputs.

This property overrides the default input formatter, which formats by calling toString() on the input value.

See also
Example
// Formats the slider input to abbreviated numbers with units
// e.g. a thumb at position 1500 will render with an input label of 1.5k
slider.inputFormatFunction = function(value, type){
if(value >= 1000000){
return (value / 1000000).toPrecision(3) + "m"
}
if(value >= 100000){
return (value / 1000).toPrecision(3) + "k"
}
if(value >= 1000){
return (value / 1000).toPrecision(2) + "k"
}
return value.toFixed(0);
}

inputParseFunction

inherited Property
Type
InputParseFunction | null | undefined
Inherited from: SmartMappingSliderBase
Since
ArcGIS Maps SDK for JavaScript 4.14

Function used to parse slider inputs formatted by the inputFormatFunction. This property must be set if an inputFormatFunction is set. Otherwise the slider values will likely not update to their expected positions.

Overrides the default input parses, which is a parsed floating point number.

See also
Example
// Parses the slider input (a string value) to a number value understandable to the slider
// This assumes the slider was already configured with an inputFormatFunction
// For example, if the input is 1.5k this function will parse
// it to a value of 1500
slider.inputParseFunction = function(value, type, index){
let charLength = value.length;
let valuePrefix = parseFloat(value.substring(0,charLength-1));
let finalChar = value.substring(charLength-1);
if(parseFloat(finalChar) >= 0){
return parseFloat(value);
}
if(finalChar === "k"){
return valuePrefix * 1000;
}
if(finalChar === "m"){
return valuePrefix * 1000000;
}
return value;
}

label

autocast Property
Type
string

The widget's default label. This label displays when it is used within another widget, such as the Expand or LayerList widgets.

labelFormatFunction

inherited Property
Type
LabelFormatFunction | null | undefined
Inherited from: SmartMappingSliderBase

A modified version of Slider.labelFormatFunction, which is a custom function used to format labels on the thumbs, min, max, and average values. Overrides the default label formatter. This function also supports date formatting.

Example
// For thumb values, rounds each label to whole numbers
slider.labelFormatFunction = function(value, type) {
return (type === "value-change") ? value.toFixed(0): value;
}

max

inherited Property
Type
number
Inherited from: SmartMappingSliderBase

The maximum value or upper bound of the slider. If the largest slider value in the constructor is greater than the max set in this property, then the max will update to match the largest slider value.

Example
slider.max = 150;

min

inherited Property
Type
number
Inherited from: SmartMappingSliderBase

The minimum value or lower bound of the slider. If the smallest slider value in the constructor is greater than the min set in this property, then the min will update to match the smallest slider value.

Example
slider.min = -150;

persistSizeRangeEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.19

Only applicable when three thumbs (i.e. handles) are set on the slider (i.e. when primaryHandleEnabled is true). This property is typically used in diverging, or above-and-below renderer configurations.

When true, ensures symbol sizes in the above range are consistent with symbol sizes in the below range for all slider thumb positions. In other words, the size values in the stops will adjust proportionally according to the positions of the data values within the constraints of the size range (maxSize - minSize) as the slider thumbs update. When false, size values in the stops will remain the same even when slider thumb values change.

In most cases, this should be set to true to keep sizes in the above range consistent with sizes in the below range to avoid map misinterpretation.

See also
Default value
false
Example
slider.primaryHandleEnabled = true;
slider.persistSizeRangeEnabled = true;

precision

inherited Property
Type
number
Inherited from: SmartMappingSliderBase
Since
ArcGIS Maps SDK for JavaScript 4.14

Defines how slider thumb values should be rounded. This number indicates the number of decimal places slider thumb values should round to when they have been moved.

This value also indicates the precision of thumb labels when the data range is less than 10 (i.e. (max - min) < 10).

When the data range is larger than 10, labels display with a precision of no more than two decimal places, though actual slider thumb values will maintain the precision specified in this property.

For example, given the default precision of 4, and the following slider configuration, The labels of the thumbs will display two decimal places, but the precision of the actual thumb values will not be lost even when the user slides or moves the thumb.

const slider = new Slider({
min: 20,
max: 100, // data range of 80
values: [50.4331],
// thumb label will display 50.43
// thumb value will maintain precision, so
// value will remain at 50.4331
container: "sliderDiv"
});

If the user manually enters a value that has a higher precision than what's indicated by this property, the precision of that thumb value will be maintained until the thumb is moved by the user. At that point, the value will be rounded according to the indicated precision.

If thumb labels aren't visible, they must be enabled with labelInputsEnabled.

Keep in mind this property rounds thumb values and shouldn't be used exclusively for formatting purposes. To format thumb labels, use the labelFormatFunction property.

Default value
4
Example
slider.precision = 7;

primaryHandleEnabled

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 4.18

When true, the slider will render a third handle between the two handles already provided by default. This is the primary handle. When handlesSyncedToPrimary is true, then this handle will control the position of the others when moved.

See also
Default value
false
Example
// enables the primary handles and syncs it with the others
slider.primaryHandleEnabled = true;
slider.handlesSyncedToPrimary = true;
slider.persistSizeRangeEnabled = true;

state

readonlyinherited Property
Type
SmartMappingSliderBaseState
Inherited from: SmartMappingSliderBase

The state of the view model.

stops

Property
Type
SizeSliderSizeStop[]

The size stops from the SizeVariable to link to the slider.

See also
Example
const slider = new SizeSlider({
container: "sliderDiv",
min: 0,
max: 100,
stops: [
{ value: 0, size: 4 },
{ value: 100, size: 40 }
]
});

style

Property
Type
SizeSliderStyle

Exposes various properties of the widget that can be styled.

Example
slider.style = {
trackFillColor: new Color("dodgerblue"),
trackBackgroundColor: new Color([50,50,50])
};

syncedSegmentsEnabled

inherited Property
Type
boolean
Inherited from: SmartMappingSliderBase
Since
ArcGIS Maps SDK for JavaScript 4.20

When true, all segments will sync together in updating thumb values when the user drags any segment. This maintains the interval between all thumbs when any segment is dragged. Only applicable when visibleElements.interactiveTrack is true.

In sliders where the primary handle is enabled, this allows you to disable handlesSyncedToPrimary to keep handle movements independent of the middle (primary) handle, but still provide an option for the end user to sync handles with the primary handle via slider drag events.

See also
Default value
false
Example
slider.visibleElements = {
interactiveTrack: true
};
slider.syncedSegmentsEnabled = true;

viewModel

autocast Property
Type
SizeSliderViewModel<SizeSliderSizeStop>

The view model for the SizeSlider widget. This class contains all the logic (properties and methods) that controls this widget's behavior. See the SizeSliderViewModel class to access all properties and methods on the SizeSlider widget.

visible

inherited Property
Type
boolean
Inherited from: Widget

Indicates whether the widget is visible.

If false, the widget will no longer be rendered in the web document. This may affect the layout of other elements or widgets in the document. For example, if this widget is the first of three widgets associated to the upper right hand corner of the DefaultUI, then the other widgets will reposition when this widget is made invisible. For more information, refer to the css display value of "none".

Default value
true
Example
// Hides the widget in the view
widget.visible = false;

visibleElements

inherited Property
Type
VisibleElements
Inherited from: SmartMappingSliderBase
Since
ArcGIS Maps SDK for JavaScript 4.20

The visible elements that are displayed within the widget. This property provides the ability to turn individual elements of the widget's display on/off.

See also
Example
slider.visibleElements = {
interactiveTrack: true
};
slider.syncedSegmentsEnabled = true;

zoomOptions

inherited Property
Type
ZoomOptions | null | undefined
Inherited from: SmartMappingSliderBase

Zooms the slider track to the bounds provided in this property. When min and/or max zoom values are provided, the absolute min and max slider values are preserved and rendered at their typical positions on the slider. However, the slider track itself is zoomed so that thumbs cannot be moved above or below the provided min and max zoomed values.

When a slider is in a zoomed state, the zoomed ends of the track will appear jagged. In the image below, notice how the top thumb cannot be moved past the zoom max of 31 even though the slider max is 200.

slider-zoom

To exit a zoomed state, the user can click the jagged line or the developer can set the zoomOptions to null. It is up to the developer to provide a UI option for end users to enable zooming on the slider.

Setting the zoomOptions is useful when the slider is tied to heavily skewed datasets where the histogram renders only one or two bars because of outliers.

slider-not-zoomed

You can remove the influence of outliers by zooming the slider and regenerating a histogram based on the zoomed min and max. This will provide a better view of the data and make the slider more useful to the end user.

Examples
// zooms the slider to so thumbs can only be moved
// to positions between the values of 10 and 25 while
// maintaining the slider's absolute minimum and
// maximum values
slider.zoomOptions = {
min: 10,
max: 25
};
// disables zooming on the slider
slider.zoomOptions = null;
// zooms the slider to so thumbs can only be moved
// to positions above the value of 10, while maintaining
// the slider's absolute minimum value
slider.zoomOptions = {
min: 10
};
// zooms the slider to so thumbs can only be moved
// to positions below the value of 25, while maintaining
// the slider's absolute maximum value
slider.zoomOptions = {
max: 25
};
// zooms the slider to the handle positions
// with some padding
document.getElementById("zoomInButton").onclick = function() {
const lowerThumb = slider.values[0];
const upperThumb = slider.values[1];
const range = upperThumb - lowerThumb;
const padding = range * 0.3;
const zoomMin = (lowerThumb - padding) > slider.min ? (lowerThumb - padding) : slider.min;
const zoomMax = (upperThumb + padding) < slider.max ? (upperThumb + padding) : slider.max;
slider.set({ zoomOptions: { min: zoomMin, max: zoomMax } });
};

Methods

MethodSignatureClass
fromRendererResult(rendererResult: ContinuousRendererResult, histogramResult?: HistogramResult): SizeSlider
classes
inherited
classes(...classNames: ((string | null | undefined) | ((string[] | Record<string, boolean>) | null | undefined) | false | null | undefined)[]): string
destroy
inherited
destroy(): void
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
isFulfilled
inherited
isFulfilled(): boolean
isRejected
inherited
isRejected(): boolean
isResolved
inherited
isResolved(): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
postInitialize
inherited
postInitialize(): void
render
inherited
render(): any | null
renderNow
inherited
renderNow(): void
scheduleRender
inherited
scheduleRender(): void
updateFromRendererResult(rendererResult: ContinuousRendererResult, histogramResult?: HistogramResult): void
updateVisualVariable(sizeVariable: SizeVariable): SizeVariable | null | undefined
when
inherited
when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>

fromRendererResult

static Method
Signature
fromRendererResult (rendererResult: ContinuousRendererResult, histogramResult?: HistogramResult): SizeSlider

A convenience function used to create a SizeSlider widget instance from the result of the createContinuousRenderer() method.

This method sets the slider stops, min, max, and histogramConfig. It is still the developer's responsibility to assign it a proper container and any other optional properties.

Parameters
ParameterTypeDescriptionRequired
rendererResult

The result object from the createContinuousRenderer() method.

histogramResult

The result histogram object from the histogram() method.

Returns
SizeSlider

Returns a SizeSlider instance. This will not render until you assign it a valid container.

Example
const params = {
layer: layer,
basemap: map.basemap,
field: "POP_POVERTY"
};
let rendererResult = null;
sizeRendererCreator
.createContinuousRenderer(colorParams)
.then(function(response) {
rendererResult = response;
layer.renderer = response.renderer;
return histogram({
layer: layer,
valueExpression: params.field,
numBins: 30
});
})
.then(function(histogramResult) {
const sizeSlider = SizeSlider.fromRendererResult(rendererResult, histogramResult);
sizeSlider.container = "slider";
// when the user slides the handle(s), update the renderer
// with the updated size properties
sizeSlider.on(["thumb-change", "thumb-drag"], function() {
const renderer = layer.renderer.clone();
const sizeVariable = renderer.visualVariables[0];
renderer.visualVariables = [ sizeSlider.updateVisualVariable( sizeVariable ) ];
layer.renderer = renderer;
});
})
.catch(function(error) {
console.log("there was an error: ", error);
});

classes

inherited Method
Signature
classes (...classNames: ((string | null | undefined) | ((string[] | Record<string, boolean>) | null | undefined) | false | null | undefined)[]): string
Inherited from: Widget

A utility method used for building the value for a widget's class property. This aids in simplifying css class setup.

Parameters
ParameterTypeDescriptionRequired
classNames
((string | null | undefined) | ((string[] | Record<string, boolean>) | null | undefined) | false | null | undefined)[]

The class names.

Returns
string

The computed class name.

Example
// .tsx syntax showing how to set css classes while rendering the widget
render() {
const dynamicClasses = {
[css.flip]: this.flip,
[css.primary]: this.primary
};
return (
<div class={classes(css.root, css.mixin, dynamicClasses)} />
);
}

destroy

inherited Method
Signature
destroy (): void
Inherited from: Widget

Destroys the widget instance.

Returns
void

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

isFulfilled

inherited Method
Signature
isFulfilled (): boolean
Inherited from: EsriPromiseMixin

isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).

isRejected

inherited Method
Signature
isRejected (): boolean
Inherited from: EsriPromiseMixin

isRejected() may be used to verify if creating an instance of the class is rejected. If it is rejected, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been rejected.

isResolved

inherited Method
Signature
isResolved (): boolean
Inherited from: EsriPromiseMixin

isResolved() may be used to verify if creating an instance of the class is resolved. If it is resolved, true will be returned.

Returns
boolean

Indicates whether creating an instance of the class has been resolved.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen called, removes the listener from the event.
Example
view.on("click", function(event){
// event is the event handle returned after the event fires.
console.log(event.mapPoint);
});

postInitialize

inherited Method
Signature
postInitialize (): void
Inherited from: Widget

Executes after widget is ready for rendering.

Returns
void

render

inherited Method
Signature
render (): any | null
Inherited from: Widget

This method is implemented by subclasses for rendering.

Returns
any | null

The rendered virtual node.

renderNow

inherited Method
Signature
renderNow (): void
Inherited from: Widget

Renders widget to the DOM immediately.

Returns
void

scheduleRender

inherited Method
Signature
scheduleRender (): void
Inherited from: Widget

Schedules widget rendering. This method is useful for changes affecting the UI.

Returns
void

updateFromRendererResult

Method
Signature
updateFromRendererResult (rendererResult: ContinuousRendererResult, histogramResult?: HistogramResult): void

A convenience function used to update the properties of a SizeSlider widget instance from the result of the createContinuousRenderer() method. This method is useful for cases when the app allows the end user to switch data variables used to render the data.

Parameters
ParameterTypeDescriptionRequired
rendererResult

The result object from the createContinuousRenderer() method.

histogramResult

The result histogram object from the histogram() method.

Returns
void
Example
const params = {
layer: layer,
basemap: map.basemap,
field: "POP_POVERTY"
};
let rendererResult = null;
sizeRendererCreator
.createContinuousRenderer(colorParams)
.then(function(response) {
rendererResult = response;
layer.renderer = response.renderer;
return histogram({
layer: layer,
valueExpression: params.field,
numBins: 30
});
})
.then(function(histogramResult) {
sizeSlider.updateFromRendererResult(rendererResult, histogramResult);
})
.catch(function(error) {
console.log("there was an error: ", error);
});

updateVisualVariable

Method
Signature
updateVisualVariable (sizeVariable: SizeVariable): SizeVariable | null | undefined

A convenience function used to update the SizeVariable to match the values of the stops on the slider.

This is particularly useful for Size visual variables that have a set SizeVariable.minDataValue and maxDataValue. This method will properly reconstruct the variable to set on the renderer so it matches the stops on the slider.

Parameters
ParameterTypeDescriptionRequired
sizeVariable

The size visual variable from the renderer to update to the set stops on the slider.

Returns
SizeVariable | null | undefined

Returns the updated visual variable to set back on the renderer.

Example
sizeSlider.on(["thumb-change", "thumb-drag"], function() {
const renderer = layer.renderer.clone();
const sizeVariable = renderer.visualVariables[0];
renderer.visualVariables = [ sizeSlider.updateVisualVariable( sizeVariable ) ];
layer.renderer = renderer;
});

when

inherited Method
Signature
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
Type parameters
<TResult1 = this, TResult2 = never>
Inherited from: EsriPromiseMixin

when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function. The onFulfilled executes when the instance of the class loads. The onRejected executes if the instance of the class fails to load.

Parameters
ParameterTypeDescriptionRequired
onFulfilled

The function to call when the promise resolves.

onRejected

The function to execute when the promise fails.

Returns
Promise<TResult1 | TResult2>

Returns a new promise for the result of onFulfilled that may be used to chain additional functions.

Example
// Although this example uses MapView, any class instance that is a promise may use when() in the same way
let view = new MapView();
view.when(function(){
// This function will execute once the promise is resolved
}, function(error){
// This function will execute if the promise is rejected due to an error
});

Events

max-change

inherited Event
Inherited from: CommonSliderEvents

Fires when a user changes the max of the slider.

bubbles composed cancelable
Example
slider.on("max-change", function() {
const renderer = layer.renderer.clone();
const visualVariable = renderer.visualVariables[0].clone();
colorVariable.stops = slider.stops;
renderer.visualVariables = [ visualVariable ];
layer.renderer = renderer;
});

min-change

inherited Event
Inherited from: CommonSliderEvents

Fires when a user changes the min of the slider.

bubbles composed cancelable
Example
slider.on("min-change", function() {
const renderer = layer.renderer.clone();
const visualVariable = renderer.visualVariables[0].clone();
colorVariable.stops = slider.stops;
renderer.visualVariables = [ visualVariable ];
layer.renderer = renderer;
});

segment-drag

inherited Event
segment-drag: CustomEvent<SegmentDragEvent>
Inherited from: CommonSliderEvents
Since
ArcGIS Maps SDK for JavaScript 4.20

Fires when a user drags a segment of the slider. A segment is the portion of the track that lies between two thumbs. Therefore, this only applies when two or more thumbs are set on the slider.

See also
bubbles composed cancelable
Example
slider.on("segment-drag", () => {
const renderer = layer.renderer.clone();
const visualVariable = renderer.visualVariables[0].clone();
colorVariable.stops = slider.stops;
renderer.visualVariables = [ visualVariable ];
layer.renderer = renderer;
});

thumb-change

inherited Event
thumb-change: CustomEvent<ThumbChangeEvent>
Inherited from: CommonSliderEvents

Fires when a user changes the value of a thumb via the arrow keys or by keyboard editing of the label on the slider.

bubbles composed cancelable
Examples
slider.on("thumb-change", function() {
const renderer = layer.renderer.clone();
const visualVariable = renderer.visualVariables[0].clone();
colorVariable.stops = slider.stops;
renderer.visualVariables = [ visualVariable ];
layer.renderer = renderer;
});
slider.on("thumb-change", function() {
const renderer = layer.renderer.clone();
renderer.colorStops = slider.stops;
layer.renderer = renderer;
});

thumb-drag

inherited Event
Inherited from: CommonSliderEvents

Fires when a user drags a thumb on the widget.

bubbles composed cancelable
Examples
slider.on("thumb-drag", function() {
const renderer = layer.renderer.clone();
const visualVariable = renderer.visualVariables[0].clone();
colorVariable.stops = slider.stops;
renderer.visualVariables = [ visualVariable ];
layer.renderer = renderer;
});
slider.on("thumb-drag", function() {
const renderer = layer.renderer.clone();
renderer.colorStops = slider.stops;
layer.renderer = renderer;
});

Type definitions

SizeSliderStyle

Type definition

trackFillColor

Property
Type
Color | undefined

The color of the slider's track. For single-color visualizations where only a Size variable is present, you should set this color to match the color of the symbol in the SimpleRenderer.

Default value
new Color([149, 149, 149])

trackBackgroundColor

Property
Type
Color | undefined

The background color of the slider's track. Generally, this color should be subdued and not interfere with the trackFillColor.

Default value
new Color([224, 224, 224])

SizeSliderSizeStop

Type definition
Supertypes
default