Skip To ContentArcGIS for DevelopersSign In Dashboard
require(["esri/widgets/TimeSlider"], function(TimeSlider) { /* code goes here */ });
Class: esri/widgets/TimeSlider
Inheritance: TimeSlider Widget Accessor
Since: ArcGIS API for JavaScript 4.12

The TimeSlider widget simplifies visualization of temporal data in your application. Before adding the TimeSlider to your application, you first should understand how it can be configured to correctly display your temporal data.

The fullTimeExtent property defines the entire time period within which you can visualize your time aware data using the TimeSlider widget. You can visualize temporal data up to a point in time, from a point in time, at an instant of time, or from data that falls within a time range by setting the mode property. The stops property defines specific locations on the TimeSlider where thumbs will snap to when manipulated. You can set this property to be either an array of dates, a number of evenly spaced stops or a specific time interval (e.g. days). The values property defines the current location of the thumbs.

widgets-timeSlider

The TimeSlider widget can be configured to manipulate your time aware data in two different ways as outlined below:

Update the view's timeExtent

The TimeSlider widget can be configured to update the view's timeExtent when the view property is set on the widget. Whenever a TimeSlider's timeExtent is updated, the assigned view's timeExtent will also be updated. All time-aware layers will automatically update to conform to the view's timeExtent.

// Create a TimeSlider for the first decade of the 21st century.
// set the TimeSlider's view property.
// Only show content for the 1st year of the decade for all
// time aware layers in the view.
var timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  view: view,
  // show data within a given time range
  // in this case data within one year
  mode: "time-window",
  fullTimeExtent: { // entire extent of the timeSlider
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values:[ // location of timeSlider thumbs
    new Date(2000, 0, 1),
    new Date(2001, 1, 1)
  ]
});
view.ui.add(timeSlider, "manual");

Watching the TimeSlider's timeExtent

The TimeSlider widget can also be configured to apply custom logic whenever the TimeSlider is manipulated by watching its timeExtent property. For example, when the TimeSlider's timeExtent is updated, you may want to update the timeExtent property of client-side filters and effects on a FeatureLayerView, CSVLayerView, GeoJSONLayerView or OGCFeatureLayerView. A FeatureFilter can be used to filter out data that is not included in the current timeExtent, and a FeatureEffect can be used to apply a visual effect to features that are included in or excluded from the current timeExtent. The FeatureEffect can only be used in a 2D MapView.

Warning: Setting both the TimeSlider's view property (explained above) and applying a timeExtent to a client-side effect may result in excluded features not being rendered to the view. This is because excluded features have been filtered out by the view's timeExtent, so the effect will not show.

// Create a time slider to update layerView filter
var timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  mode: "cumulative-from-start",
});
view.ui.add(timeSlider, "manual");

// wait until the layer view is loaded
let timeLayerView;
view.whenLayerView(layer).then(function(layerView) {
  timeLayerView = layerView;
  const fullTimeExtent = layer.timeInfo.fullTimeExtent;
  const start = fullTimeExtent.start;

  // set up time slider properties based on layer timeInfo
  timeSlider.fullTimeExtent = fullTimeExtent;
  timeSlider.values = [start];
  timeSlider.stops = {
    interval: layer.timeInfo.interval
  };
});

timeSlider.watch("timeExtent", function(value){
  // update layer view filter to reflect current timeExtent
  timeLayerView.filter = {
    timeExtent: value
  };
});
For information about gaining full control of widget styles, see the Styling topic.
See also:

Constructors

new TimeSlider(properties)
Parameter:
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
NameTypeSummaryClass
String|HTMLElement

The ID or node representing the DOM element containing the widget.

more details
more detailsWidget
String

The name of the class.

more details
more detailsAccessor
Boolean

When true, sets the widget to a disabled state so the user cannot interact with it.

more details
more detailsTimeSlider
Date[]

Lists the specific locations on the timeline where handle(s) will snap to when manipulated.

more details
more detailsTimeSlider
TimeExtent

The temporal extent of the entire slider.

more details
more detailsTimeSlider
String

The widget's default CSS icon class.

more details
more detailsTimeSlider
String

The unique ID assigned to the widget when the widget is created.

more details
more detailsWidget
String

The widget's default label.

more details
more detailsTimeSlider
DateLabelFormatter

A function used to specify custom formatting and styling of the min, max, and extent labels of the TimeSlider.

more details
more detailsTimeSlider
String

Determines the layout used by the TimeSlider widget.

more details
more detailsTimeSlider
Boolean

When true, the time slider will play its animation in a loop.

more details
more detailsTimeSlider
String

The time slider mode.

more details
more detailsTimeSlider
Number

The time (in milliseconds) between animation steps.

more details
more detailsTimeSlider
StopsByDates|StopsByCount|StopsByInterval

Defines specific locations on the time slider where thumbs will snap to when manipulated.

more details
more detailsTimeSlider
TickConfig[]

When set, overrides the default TimeSlider ticks labelling system.

more details
more detailsTimeSlider
TimeExtent

The current time extent of the time slider.

more details
more detailsTimeSlider
Boolean

Shows/hides time in the display.

more details
more detailsTimeSlider
Date[]

The user defined time extent.

more details
more detailsTimeSlider
MapView|SceneView

A reference to the MapView or SceneView.

more details
more detailsTimeSlider
TimeSliderViewModel

The view model for this widget.

more details
more detailsTimeSlider

Property Details

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 cases 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 Stringreadonly inherited

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

disabled Boolean
Since: ArcGIS API for JavaScript 4.16

When true, sets the widget to a disabled state so the user cannot interact with it.

Default Value:false
Example:
// Create a timeslider widget that is initially disabled.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 5, 1),
    end: new Date(2010, 0, 1)
  },
  disabled: true
});
effectiveStops Date[]readonly

Lists the specific locations on the timeline where handle(s) will snap to when manipulated.

Default Value:null
Example:
// Add yearly stops starting from the beginning of 2001.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 5, 1),
    end: new Date(2010, 0, 1)
  },
  stops: {
    interval: {
      value: 1,
      unit: "years"
    },
    timeExtent: {
      start: new Date(2001, 0, 1),
      end: new Date(2010, 0, 1)
   }
  }
});
timeSlider.effectiveStops.forEach((stop) => {
  console.log(stop);
});
fullTimeExtent TimeExtentautocast

The temporal extent of the entire slider. It defines the entire time period within which you can visualize your time aware data using the time slider widget.

Example:
// Create a new TimeSlider with set dates
var timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  view: view
});

// wait for the time-aware layer to load
layer.when(function() {
  // set up time slider properties based on layer timeInfo
  timeSlider.fullTimeExtent = layer.timeInfo.fullTimeExtent;
  timeSlider.stops = {
   interval: layer.timeInfo.interval
  };
});
iconClass Stringreadonly

The widget's default CSS icon class.

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.

label String

The widget's default label.

labelFormatFunction DateLabelFormatter
Since: ArcGIS API for JavaScript 4.17

A function used to specify custom formatting and styling of the min, max, and extent labels of the TimeSlider. Please refer to DateLabelFormatter for more detailed information on how to configure the style and format of the labels.

The image below demonstrates how the date format, color, size, and font family of the label can be customized. The code for this specific configuration is shown in the following example.

timeslider-custom-labels

Default Value:null
Example:
// The following example customizes the text and styling of the min, max and extent labels.
// Specifically:
// 1) min/max labels
//    - short date format with en-us locale (e.g. "9/1/2020", "9/2/2020", "9/3/2020" etc)
//    - use 'Orbitron' font, magenta color and 16pt size
// 2) extent label
//    - display accumulated days (e.g. "Day 0", "Day 1", "Day 2" etc)
//    - use 'Orbitron' font, red color and 22pt size
const timeSlider = new TimeSlider({
  container: "timeSlider",
  fullTimeExtent: {
    start: new Date(2020, 8, 1),
    end: new Date(2020, 8, 8)
  },
  stops: {
    interval: {
      value: 1,
      unit: "days"
    }
  },
  mode: "instant",
  labelFormatFunction: (value, type, element, layout) => {
    const normal = new Intl.DateTimeFormat('en-us');
    switch (type) {
      case "min":
      case "max":
        element.setAttribute("style", "font-family: 'Orbitron', sans-serif; font-size: 16px; color: magenta;");
        element.innerText = normal.format(value);
        break;
      case "extent":
        const start = timeSlider.fullTimeExtent.start;
        const days = (value[0].getTime() - start.getTime()) / 1000 / 3600 / 24;
        element.setAttribute(`style`, `font-family: 'Orbitron', sans-serif; font-size: 22px; color: red;`);
        element.innerText = `Day ${days}`;
        break;
    }
  }
});
layout String
Since: ArcGIS API for JavaScript 4.16

Determines the layout used by the TimeSlider widget.

Possible values are listed below:

ValueDescription
autoAutomatically uses the "compact" layout when the widget width is less than 858 pixels. Otherwise the "wide" layout it used.
compactWidget elements are oriented vertically. This layout is better suited to narrower widths.
wideWidget elements are oriented laterally. This thinner design is better suited to wide applications.

Possible Values:"auto"|"compact"|"wide"

Default Value:auto
Example:
timeSlider.layout = "compact";
loop Boolean

When true, the time slider will play its animation in a loop.

Default Value:false
Example:
// Start a time slider animation that advances every second
// and restarts when it reaches the end.
timeSlider.set({
  loop: true,
  playRate: 1000
});
timeSlider.play();
mode String

The time slider mode. This property is used for defining if the temporal data will be displayed cumulatively up to a point in time, a single instant in time, or within a time range. See the following table for possible values.

Possible ValuesDescriptionExample
instantThe slider will show temporal data that falls on a single instance in time. Set the values property to an array with one date.mode-instance
time-windowThe slider will show temporal data that falls within a given time range. This is the default. Set values property to an array with two dates.mode-instance
cumulative-from-startSimilar to time-window with the start time is always pinned to the start of the slider. Set the values property to have one date, which is the end date.mode-instance
cumulative-from-endAlso, similar to the time-window with the end time pinned to the end of the slider. Set the values property to have one date, which is the start date.mode-instance

Possible Values:"instant"|"time-window"|"cumulative-from-start"|"cumulative-from-end"

Default Value:"time-window"
See also:
Example:
// Create a single thumbed time slider that includes all historic content.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  view: view,
  mode: "cumulative-from-start",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values: [new Date(2001, 0, 1)] //end date
});
playRate Number

The time (in milliseconds) between animation steps.

Default Value:1000
Example:
// Start a time slider animation that advances
// ten times a second and stops when it reaches the end.
timeSlider.set({
  loop: false,
  playRate: 100
});
timeSlider.play();
Autocasts from Object

Defines specific locations on the time slider where thumbs will snap to when manipulated. If unspecified, ten evenly spaced stops will be added.

To define regularly spaced stops based on specified time interval and time extent, use StopsByInterval. Use StopsByCount to define evenly spaced timeline stops. Lastly, for irregular dates use StopsByDates. Please refer below for examples of each of these objects.

If a declaration using StopsByInterval will result in excess of 10,000 stops then TimeSlider will default to generating ten evenly spaced stops.

Default Value:{ count : 10 }
Example:
// Add yearly stops starting from the beginning of 2001.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 5, 1),
    end: new Date(2010, 0, 1)
  },
  stops: {
    interval: {
      value: 1,
      unit: "years"
    },
    timeExtent: {
      start: new Date(2001, 0, 1),
      end: new Date(2010, 0, 1)
    }
  }
});

// Add ten stops that are evenly distributed for the year 2005 only.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 5, 1),
    end: new Date(2010, 0, 1)
  },
  stops: {
    count: 10,
    timeExtent: {
      start: new Date(2005, 0, 1),
      end: new Date(2006, 0, 1)
    }
  }
});

// Explicitly define nine stops.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values: [
    new Date(2000, 0, 1),
    new Date(2000, 0, 1)],
  stops: {
    dates: [
      new Date(2000, 0, 1), new Date(2001, 3, 8), new Date(2002, 0, 10),
      new Date(2003, 12, 8), new Date(2004, 2, 19), new Date(2005, 7, 5),
      new Date(2006, 9, 11), new Date(2007, 11, 21), new Date(2008, 1, 10)
    ]
  }
});
tickConfigs TickConfig[]
Since: ArcGIS API for JavaScript 4.16

When set, overrides the default TimeSlider ticks labelling system. Please refer to TickConfig for detailed documentation on how to configure tick placement, style, and behavior.

Default Value:null
Examples:
// By default in "en-US" the TimeSlider will display ticks with "2010, 2011, 2012, etc".
// Overwrite TimeSlider tick configuration so that labels display "'10, '12, '14, etc" in red.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2010, 0, 1),
    end: new Date(2020, 0, 1)
  },
  tickConfigs: [{
    mode: "position",
    values: [
      new Date(2010, 0, 1), new Date(2012, 0, 1), new Date(2014, 0, 1),
      new Date(2016, 0, 1), new Date(2018, 0, 1), new Date(2020, 0, 1)
    ].map((date) => date.getTime()),
    labelsVisible: true,
    labelFormatFunction: (value) => {
      const date = new Date(value);
      return `'${date.getUTCFullYear() - 2000}`;
    },
    tickCreatedFunction: (value, tickElement, labelElement) => {
      tickElement.classList.add("custom-ticks");
      labelElement.classList.add("custom-labels");
    }
  }]
};
// this CSS goes with the snippet above.
#timeSlider .custom-ticks {
  background-color: red;
  width: 1px;
  height: 8px;
}
#timeSlider .custom-labels {
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 15px;
  color: red;
}
timeExtent TimeExtentreadonly

The current time extent of the time slider. This property can be watched for updates and used to update the time extent property in queries and/or the layer filters and effects. The following table shows the timeExtent values returned for each mode.

ModeThe timeExtent value
time-window{start: startDate, end: endDate}
instant{start: sameDate, end: sameDate}
cumulative-from-start{start: null, end: endDate}
cumulative-from-end{start: startDate, end: null}
Default Value:null
Example:
// Display the time extent to the console whenever it changes.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  mode: "time-window",
  fullTimeExtent: {
    start: new Date(2019, 2, 3),
    end: new Date(2019, 2, 5)
  },
  values: [
    new Date(2019, 2, 1),
    new Date(2019, 2, 28)
  ]
});
timeSlider.watch("timeExtent", function(timeExtent){
  console.log("Time extent now starts at", timeExtent.start, "and finishes at:", timeExtent.end);
});
timeVisible Boolean

Shows/hides time in the display.

Default Value:false
Example:
// For time sliders with a small time extent it may be useful to display times as shown below.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  mode: "time-window",
  timeVisible: true,
  fullTimeExtent: {
    start: new Date(2019, 2, 3),
    end: new Date(2019, 2, 5)
  },
  values: [
    new Date(2019, 2, 1),
    new Date(2019, 2, 28)
  ]
});
values Date[]

The user defined time extent. Values define the current location of time slider thumbs. The "time-window" mode has two values, the other modes only have one.

Default Value:null
Example:
// Create a time slider and print handle positions to the console whenever they change.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  view: view,
  mode: "instant",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values: [
    new Date(2000, 0, 1) // Initialize the current time for the beginning of the fullTimeExtent.
  ]
});
timeSlider.watch("values", function(values){
  console.log("The current time is: ", values[0]);
});

A reference to the MapView or SceneView. If this property is set, the TimeSlider widget will update the view's timeExtent property whenever the time slider is manipulated or updated programmatically. This property will affect any time-aware layer in the view.

Example:
// Create and then add a TimeSlider widget and then listen to changes in the View's time extent.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  view: view,
  mode: "instant",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values: [new Date(2000, 0, 1)]
});
view.ui.add(timeSlider, "top-left");

view.watch("timeExtent", function(timeExtent){
  console.log("New view time is: ", timeExtent.start);
});

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

Example:
// Below is an example of initializing a TimeSlider widget using properties
// on the viewModel instead of the widget.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  viewModel: {
    view: view,
    mode: "instant",
    fullTimeExtent: {
      start: new Date(2000, 0, 1),
      end: new Date(2010, 0, 1)
    },
    values: [new Date(2000, 0, 1)]
  }
});

Method Overview

NameReturn TypeSummaryClass
String

A utility method used for building the value for a widget's class property.

more details
more detailsWidget

Destroys the widget instance.

more details
more detailsWidget
Boolean

Emits an event on the instance.

more details
more detailsWidget
Boolean

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

more details
more detailsWidget

Incrementally moves the time extent forward one stop.

more details
more detailsTimeSlider
Object

Registers an event handler on the instance.

more details
more detailsWidget

Widget teardown helper.

more details
more detailsWidget

Initiates the time slider's temporal playback.

more details
more detailsTimeSlider

This method is primarily used by developers when implementing custom widgets.

more details
more detailsWidget

Incrementally moves the time extent back one stop.

more details
more detailsTimeSlider
Object

This method is primarily used by developers when implementing custom widgets.

more details
more detailsWidget

Renders widget to the DOM immediately.

more details
more detailsWidget

This method is primarily used by developers when implementing custom widgets.

more details
more detailsWidget

Stops the time slider's temporal playback.

more details
more detailsTimeSlider

Method Details

classes(classNames){String}inherited

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

Parameter:
repeatable

The class names.

Returns:
TypeDescription
StringThe computed class name.
See also:
Example:
// .tsx syntax showing how to set CSS classes while rendering the widget

render() {
  const dynamicIconClasses = {
    [CSS.myIcon]: this.showIcon,
    [CSS.greyIcon]: !this.showIcon
  };

  return (
    <div class={classes(CSS.root, CSS.mixin, dynamicIconClasses)} />
  );
}
destroy()inherited

Destroys the widget instance.

emit(type, event){Boolean}inherited

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

Parameters:
type String

The name of the event.

event Object
optional

The event payload.

Returns:
TypeDescription
Booleantrue if a listener was notified
hasEventListener(type){Boolean}inherited

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

Parameter:
type String

The name of the event.

Returns:
TypeDescription
BooleanReturns true if the class supports the input event.

Incrementally moves the time extent forward one stop.

Example:
// Advance the slider's time extent.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  mode: "instant",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2010, 0, 1)
  },
  values: [new Date(2000, 0, 1)]
});
timeSlider.next();
on(type, listener){Object}inherited

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

Parameters:

A event type, or an array of event types, to listen for.

listener Function

The function to call when the event is fired.

Returns:
TypeDescription
ObjectReturns an event handler with a remove() method that can 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);
});
own(handles)inherited

Widget teardown helper. Any handles added to it will be automatically removed when the widget is destroyed.

Parameter:

Handles marked for removal once the widget is destroyed.

play()

Initiates the time slider's temporal playback.

Example:
// Start a TimeSlider animation if not already playing.
if (timeSlider.state === "ready") {
  timeSlider.play();
}
postInitialize()inherited

This method is primarily used by developers when implementing custom widgets. Executes after widget is ready for rendering.

Incrementally moves the time extent back one stop.

Example:
timeSlider.previous();
render(){Object}inherited

This method is primarily used by developers when implementing custom widgets. It must be implemented by subclasses for rendering.

Returns:
TypeDescription
ObjectThe rendered virtual node.
renderNow()inherited

Renders widget to the DOM immediately.

scheduleRender()inherited

This method is primarily used by developers when implementing custom widgets. Schedules widget rendering. This method is useful for changes affecting the UI.

stop()

Stops the time slider's temporal playback.

Example:
// Stop the current TimeSlider animation.
if (timeSlider.viewModel.state === "playing") {
  timeSlider.stop();
}

Type Definitions

DateLabelFormatter(value, type, element, layout)

This function is used by the labelFormatFunction property to specify custom formatting and styling of the min, max and extent labels.

Parameters:
value Date|Date[]

The date(s) that the corresponding label represents. When the label type is min or max a single date value will be parsed. When the type is extent value will be an array of dates. The array will contain one date if the mode is instant, cumulative-from-start or cumulative-from-end and two dates if the mode is time-window.

type String
optional

The label type that you want to format.

Possible Values:"min"|"max"|"extent"

element HTMLElement
optional

The HTML element corresponding to the label type. You can add or modify the default style of individual labels by adding CSS classes to this element. You can also add custom behavior to labels by attaching event listeners. to individual elements.

layout String
optional

The current TimeSlider layout.

Possible Values:"compact"|"wide"

StopsByCount Object

Divides the time slider's fullTimeExtent into equal parts. A stop will be placed at the start and end of each division resulting in count + 1 effectiveStops.

Properties:
count Number

Number of evenly spaced divisions.

timeExtent TimeExtent
optional

The time period to divide. If unspecified, the time slider's fullTimeExtent will be used.

Example:
// Add ten evenly spaced stops.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2004, 2, 19)
  },
  values: [
    new Date(2000, 0, 1),
    new Date(2000, 3, 8)
  ],
  stops: {
    count: 10
  }
});
StopsByDates Object

Specifies an array of dates for the time slider widget. Can be used to create irregularly spaced stops.

Property:
dates Date[]

Array of dates.

Example:
// Explicitly define 5 stops.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2004, 2, 19)
  },
  values: [
    new Date(2000, 0, 1),
    new Date(2001, 3, 8)
  ],
  stops: {
    dates: [
      new Date(2000, 0, 1),
      new Date(2001, 3, 8),
      new Date(2002, 0, 10),
      new Date(2003, 12, 8),
      new Date(2004, 2, 19)
    ]
  }
});
StopsByInterval Object

Defines regularly spaced stops on the time slider from a TimeInterval. The optional TimeExtent can confine the subdivision to a specific time frame. StopByInterval is useful when the spacing is in terms of months and years, which cannot be reliably expressed in milliseconds.

Properties:
interval TimeInterval

Specifies a granularity of temporal data and allows you to visualize the data at specified intervals. It can be set at regular interval such as every hour or every day.

timeExtent TimeExtent
optional

A period of time with definitive start and end dates. The time slider widget's fullTimeExtent will be used if this property is not specified.

Example:
// Add yearly intervals starting from the beginning of the TimeSlider.
const timeSlider = new TimeSlider({
  container: "timeSliderDiv",
  fullTimeExtent: {
    start: new Date(2000, 0, 1),
    end: new Date(2015, 2, 19)
  },
  values: [
    new Date(2000, 0, 1),
    new Date(2001, 0, 1)
  ],
  stops: {
    interval: {
      value: 1,
      unit: "years"
    }
  }
});

API Reference search results

NameTypeModule
Loading...