Class: TimeSlider

Description

Class added 2.0.
dojo.require("esri.dijit.TimeSlider");

Wigdet for visualizing time enabled layers.

Samples

Search for samples that use this class.  

Class hierarchy

esri.dijit.TimeSlider

Constructor

Constructor Description
esri.dijit.TimeSlider(params, srcNodeRef) Creates a new TimeSlider object.

Properties

Property Type Description
loop Boolean Default value is false.
playing Boolean Default value is false.
thumbCount Number Default value is 1.
thumbMovingRate Number Rate at which the time animation plays. Default value is 1000 milliseconds.
timeStops Date[] An array of dates representing the stops (tics) on the TimeSlider.

Methods

Method Return Value Description
createTimeStopsByCount(timeExtent, count?) none The specified number of time stops are created for the input time extent.
createTimeStopsByTimeInteval(timeExtent, timeInterval?, timeIntervalUnits?) none Create a time stop for each interval specified, i.e.(week,month, day).
getCurrentTimeExtent() TimeExtent Gets the current time extent for the time slider.
next() none Move to the next time step.
pause() none Pause the time slider.
play() none Play the time slider.
previous() none Move to the previous time step.
setLabels(labels) none Specify an array of strings to be used as labels. The array position for each string defines which tick it will be placed on.
setLoop(loop) none Determines whether or not loop. Default value is false.
setThumbCount(thumbCount) none The number of thumbs to display. A value of one displays a single thumb. Setting the value to 2 displays a range slider.
setThumbIndexes(indexes) none Array of two integers, the first value determins where to put the first thumb. If it is a two thumb slider the second value determines where to place the additional thumb.
setThumbMovingRate(thumbMovingRate) none Change the rate at which the time animation plays.
setTickCount(count) none Specify the number of ticks to display on the time slider.
setTimeStops(timeStops) none Manually define the time stop locations by providing an array of dates.
singleThumbAsTimeInstant(createTimeInstants) none Determine if the time is displayed for an instant in time. Only valid when the thumb count is set to one.

Events

Event Description
onTimeExtentChange(timeExtent) Fires when the timeExtent of the TimeSlider is changed.
Constructor Detail

esri.dijit.TimeSlider(params, srcNodeRef)

Creates a new TimeSlider object.
Parameters:
<String> params Required Parameters for the time slider object. See the options table below for parameters.
<Object> srcNodeRef Required HTML element where the time slider should be rendered.
Options:
<Boolean> excludeDataAtLeadingThumb When true, subtracts one second to the time extent's end time to exclude data at the exact end time instant.
<Boolean> excludeDataAtTrailingThumb When true, adds one second to the time extent's start time to exclude data at the exact start time instant.
Properties Detail

<Boolean> loop

Default value is false.

<Boolean> playing

Default value is false.

<Number> thumbCount

Default value is 1.

<Number> thumbMovingRate

Rate at which the time animation plays. Default value is 1000 milliseconds.

<Date[]> timeStops

An array of dates representing the stops (tics) on the TimeSlider.
Methods Detail

createTimeStopsByCount(timeExtent, count?)

The specified number of time stops are created for the input time extent.
Return value: none
Input Parameters:
<TimeExtent> timeExtent Required The time extent used to define the time slider's start and end time stops.
<Number> count Optional The number of time stops to create.

createTimeStopsByTimeInteval(timeExtent, timeInterval?, timeIntervalUnits?)

Create a time stop for each interval specified, i.e.(week,month, day).
Return value: none
Input Parameters:
<TimeExtent> timeExtent Required The time extent used to define the time slider's start and end time stops.
<Number> timeInterval Optional The length of the time interval.
<String> timeIntervalUnits Optional Valid values are listed in the TimeInfo constants table.
Code snippets:
dojo.connect(map,"onLayersAddResult",function(results){
  timeSlider = new esri.dijit.TimeSlider({},dojo.byId("timeSliderDiv"));
  map.setTimeSlider(timeSlider);        
  timeSlider.setThumbCount(1);
  timeSlider.createTimeStopsByTimeInterval(results[1].layer.timeInfo.timeExtent,1,'esriTimeUnitsWeeks');
  timeSlider.startup();
})

getCurrentTimeExtent()

Gets the current time extent for the time slider.
Return value: TimeExtent
Code snippets:
      var startTime = timeSlider.getCurrentTimeExtent().startTime;

next()

Move to the next time step.
Return value: none

pause()

Pause the time slider.
Return value: none

play()

Play the time slider.
Return value: none

previous()

Move to the previous time step.
Return value: none

setLabels(labels)

Specify an array of strings to be used as labels. The array position for each string defines which tick it will be placed on.
Return value: none
Input Parameters:
<String[]> labels Required An array of strings that define the labels for each tick.
Code snippets:

Add a label for every other tick.

var labels = dojo.map(timeSlider.timeStops, function(timeStop,i){ 
  if(i%2 === 0){
    return timeStop.getUTCFullYear(); }
  else{
    return "";
  }
});	
timeSlider.setLabels(labels);

setLoop(loop)

Determines whether or not loop. Default value is false.
Return value: none
Input Parameters:
<Boolean> loop Required True plays the time slider continuously. Default value is false.
Code snippets:
timeSlider.setLoop(true);

setThumbCount(thumbCount)

The number of thumbs to display. A value of one displays a single thumb. Setting the value to 2 displays a range slider.
Return value: none
Input Parameters:
<Number> thumbCount Required The number of thumbs to display. Default value is one.
Code snippets:
timeSlider.setThumbCount(2);

setThumbIndexes(indexes)

Array of two integers, the first value determins where to put the first thumb. If it is a two thumb slider the second value determines where to place the additional thumb.
Return value: none
Input Parameters:
<Array> indexes Required Array of two integers.
Code snippets:
timeSlider.setThumbCount(2);
timeSlider.setThumbIndexes([0,1]);

setThumbMovingRate(thumbMovingRate)

Change the rate at which the time animation plays.
Return value: none
Input Parameters:
<Number> thumbMovingRate Required The rate at which the time slider plays. Default value is 1500.
Code snippets:
timeSlider.setThumbMovingRate(2000);

setTickCount(count)

Specify the number of ticks to display on the time slider. (As of v2.1)
Return value: none
Input Parameters:
<Number> count Required The number of ticks to display on the slider.
Code snippets:
timeSlider.setTickCount(dojo.date.difference(timeExtent.startTime,timeExtent.endTime,"day"));

setTimeStops(timeStops)

Manually define the time stop locations by providing an array of dates.
Return value: none
Input Parameters:
<Date[]> timeStops Required Array of dates
Code snippets:
var myTimeStepIntervals = [new Date("01/01/1970"), new Date("01/01/1971"), new Date("01/01/1972"),
    new Date("01/01/1973"), new Date("01/01/1974"),new Date("01/01/1975"), new Date("01/01/1976")];
timeSlider.setTimeStops(myTimeStepIntervals);

singleThumbAsTimeInstant(createTimeInstants)

Determine if the time is displayed for an instant in time. Only valid when the thumb count is set to one.
Return value: none
Input Parameters:
<Boolean> createTimeInstants Required When true, the time slider displays features for the current point in time. When false cumulative data is displayed from the start time to the current thumb location. The default value is false.
Code snippets:
 timeSlider.singleThumbAsTimeInstant(true);

Events Detail

onTimeExtentChange(timeExtent)

Fires when the timeExtent of the TimeSlider is changed.
Arguments:
<TimeExtent> timeExtent The current time slice of the time slider.
Code snippets:
dojo.connect(timeSlider,"onTimeExtentChange",extentChanged);
function extentChanged(timeExtent){
  //format the dates for display
  var startVal = timeExtent.startTime.getFullYear();
  var endVal = timeExtent.endTime.getFullYear();
  dojo.byId("timeVal").innerHTML = " Current Time Extent:" + startVal + " TO " + endVal  + "<\/b>";
}