Timeline - changing the visible range

I have a Timeline object which is showing several thousand data points over a 4 day range (for example). As part of constructing the timeline, I have stored the max value of the data, and the time at which it occurred. I would like to be able to click a button and zoom the Timeline to show one hour around that maximum value…

I tried the following - (I have removed a lot of supporting code that identifies which graph is being worked on etc…)

Calendar cal = Calendar.getInstance();
Date startDate = null;
Date endDate = null;

String maxTime = hm_MinTime.get(gf);
Timeline tl = null;

jg = gf.getJartGraph();
tl = jg.getgTL(); // Pick up the timeline object
cal = setTimeValue(maxTime); // Creates a Calendar object at the time that should be in the ‘center’ of my window
cal.add(Calendar.MINUTE, (-60)); // Back one hour
startDate = cal.getTime();
cal.add(Calendar.MINUTE, 120); // Forward 2 hours…
tl.setVisibleDateRange(startDate, endDate);

When I do this, nothing happens - the graph does not redraw or re-scale. Unfortunately, if I attempt to just ‘redraw’ the graph, it will go back and pick up my 4 days worth of data and redisplay it, and that isn’t what I want to do…

Is there something I need to do to force the Timeline object to rescale? Do I need to reload the data source manually with just the data points in that new time range? That will probably work, but I was hoping not to have to do that…



Is your endDate still null at that point or have you just accidentally removed that part as well? Haven’t used Timeline so I don’t know what null endDate would do, but it probably isn’t what you were after… And since I haven’t used Timeline that’s the best I can offer, unfortunately. Aside from trying requestRepaint() that is…

Hi Neal,

You are right, it looks like calling Timeline.setVisibleDateRange() after the Timeline has initialized does not have any effect. I’ve created a ticket about this issue at

Thanks John - I’ll look for a new version when you fix it. At the same time, kudos to Anna for spotting the line I left out when I was cutting/pasting the sample code - I actually am setting the endDate variable, and I would have felt very silly if that had been the problem - I stared at that code a long time before writing this question… Thanks again,


Version 1.2.3 of the Vaadin Timeline should fix this (and some other issues as well). Should be available in the Directory shortly.

Hi John,

I just downloaded version 1.2.3 and gave it a try, but it did not redraw my graph. Here is the entire function - when I click this button, it should set the date range to 1 hour +/- the location of the minimum value on the graph. Am I setting the parameters incorrectly?




bZoomToMin.addListener(new Button.ClickListener(){
private static final long serialVersionUID = 1L;

			public void buttonClick(ClickEvent event) {
				Calendar cal = Calendar.getInstance();
				Date startDate = null;
				Date endDate = null;
				GraphFrame gf = (GraphFrame) bZoomToMin.getData();
				JartGraph jg = null;
				String minTime = hm_MinTime.get(gf);
				Timeline tl = null;

				Logger.info("Min Time: " + minTime);
				jg = gf.getJartGraph();
				tl = jg.getgTL();
				cal = setTimeValue(minTime);
				Logger.info("Date = " + (cal.get(Calendar.MONTH) + 1) +
						"/" + cal.get(Calendar.DAY_OF_MONTH) + "/" +
						cal.get(Calendar.YEAR) + "   " +
						cal.get(Calendar.HOUR_OF_DAY) + ":" +
				cal.add(Calendar.MINUTE, (-60));
				startDate = cal.getTime();
				cal.add(Calendar.MINUTE, 120);
				endDate = cal.getTime();
                                    Logger.info("Start: " + startDate.toString());
				Logger.info("End  : " + endDate.toString());
				tl.setVisibleDateRange(startDate, endDate);


The log file shows this when the button is clicked (and those are the correct times):

Min Time: 12/5/2011 21:0
Date = 12/5/2011 21:0
Start: Mon Dec 05 20:00:13 EST 2011
End : Mon Dec 05 22:00:13 EST 2011

That is odd, I have a similar test case and it is working for me.

Are you sure you’ve updated your widgetset after you updated the timeline jar? The fix was a pure client side fix so for it to work you will need to rebuild the widgetset.

If it is not the widgetset then it could also be data related, could you check if there appears any red error messages in the debug window when you click the button. If so post them here and I’ll take a look.

Finally, if all else fails try to make a small test application with similar data you have and where setting the visible range fails. That way I can fix it much faster when I have a testcase to work with.

My apologies - usually Eclipse tells me to recompile widgetsets when it detects a new one - It didn’t, and I did not rebuild it yesterday. I’ll keep that in mind for the future…

So yes, it is now working. Thanks very much!