3

I want to customize the time slider. Currently I am using "esriTimeUnitsMonths" in which I am getting only months not the year (Please check the imagescreenshot)

I want to put month name +year ex. Jan 09 Feb 09 like that..

I researched on google but I am not able find suitable information. Some one told me that create the array but we can use array on time slider.

Any help will be great..thanks in advance : )

Software : ArcGIS Server 10.1 & ArcGIS Java Script API 3.1

Code: `

var timeExtent = new esri.TimeExtent();
 timeExtent.startTime = new Date("1/1/2009 UTC");
 timeExtent.endTime = new Date("12/31/2011 UTC");
 timeSlider.setLoop(true);
 timeSlider.setThumbCount(2);
 //timeSlider.setTickCount(dojo.date.difference(timeExtent.startTime,timeExtent.endTime,"Months"));
 // original timeSlider.createTimeStopsByTimeInterval(timeExtent,1,'esriTimeUnitsMonths');
 timeSlider.createTimeStopsByTimeInterval(timeExtent,1,'esriTimeUnitsMonths');
 //timeSlider.createTimeStopsByTimeInterval(timeExtent,1,'esriTimeUnitsYears');
 timeSlider.setThumbIndexes([0,1]);
 // timeSlider.timeStops(3);
 timeSlider.setThumbMovingRate(1000);
 timeSlider.startup();`
Mapperz
50.6k9 gold badges76 silver badges133 bronze badges
asked Nov 2, 2012 at 12:09

1 Answer 1

4

Generate your own array of labels, and then specify them on the time slider using TimeSlider.setLabels.

Here's code I put together to do this, use this after you've called timeSlider.startup():

var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
//add labels for every other time stop
var labels = dojo.map(timeSlider.timeStops, function(timeStop,i){ 
 if ( i % 2 ) {
 var m = months[timeStop.getMonth()];
 var y = (timeStop.getFullYear() - 2000);
 var py = (y < 10) ? "0" + y : y;
 var lbl = m + " " + py;
 console.log("time stop: ", lbl);
 return lbl;
 } else {
 return "";
 }
}); 
timeSlider.setLabels(labels);

The code above will label every other tick instead of every tick. Labeling every tick clutters up the bottom of the slider and makes all labels hard to read. This technique is also shown in the Time Slider sample.

answered Nov 2, 2012 at 14:54
2
  • Hello Derek, Thanks for your answer..I will try this and let you know..thanks once again : ) Commented Nov 2, 2012 at 19:00
  • Thank you very much...still getting an error but I will find out the..it almost resolved..thanks once again : ) Commented Nov 3, 2012 at 11:03

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.