Gu Wei Xing, Software developer in NanTong of JiangSu province, China.
Feb 05, 2007
Version
Applicable to ZK 2.2.0 and later.
Timeline is a DHTML-based AJAX widget for visualizing time-based events. It is like Google Maps for time-based information. For more details please visit http://simile.mit.edu/timeline/.
Now I have packaged the SIMILE Timeline to a ZK component. Here I will demonstrate how to use it.
<window id="win">
<timeline height="300px" width="100%">
<bandinfo width="70%" intervalUnit="month" intervalPixels="100">
</bandinfo>
<bandinfo width="30%" intervalUnit="year" intervalPixels="200">
</bandinfo>
</timeline>
</window>
Run your web application and in browser you should see the timeline with two bands like following:
<window id="win">
<timeline height="300px" width="100%">
<bandinfo width="70%" id="b1" intervalUnit="month"
intervalPixels="100" eventSourceUrl="data/example1.xml">
</bandinfo>
<bandinfo width="30%" intervalUnit="year" intervalPixels="200"
syncWith="b1" eventSourceUrl="data/example1.xml">
</bandinfo>
</timeline>
</window>
The events appear in timeline component.
<window id="win">
<timeline height="300px" width="100%">
<bandinfo width="70%" id="b1" intervalUnit="month"
intervalPixels="100" eventSourceUrl="data/example1.xml">
</bandinfo>
<bandinfo width="30%" intervalUnit="year" intervalPixels="200"
syncWith="b1" eventSourceUrl="data/example1.xml"
trackHeight="0.5" trackGap="0.2" showEventText="false">
</bandinfo>
</timeline>
</window>
<window id="win">
<timeline height="300px" width="100%">
<bandinfo width="70%" id="b1" intervalUnit="month"
intervalPixels="100" eventSourceUrl="data/example2.xml">
</bandinfo>
<bandinfo width="30%" intervalUnit="year" intervalPixels="200"
syncWith="b1" eventSourceUrl="data/example2.xml"
trackHeight="0.5" trackGap="0.2" showEventText="false">
</bandinfo>
</timeline>
</window>
<window id="win">
<zscript>
<![CDATA[
import java.util.Date;
import java.util.TimeZone;
TimeZone zone=TimeZone.getTimeZone("GMT-05");
Date current=new Date(Date.parse("Jun 28 2006 00:00:00 GMT-0500"));
//for hotzone of band #1
Date d1=new Date(Date.parse("Aug 01 2006 00:00:00 GMT-0500"));
Date d2=new Date(Date.parse("Sep 01 2006 00:00:00 GMT-0500"));
Date d3=new Date(Date.parse("Aug 02 2006 00:00:00 GMT-0500"));
Date d4=new Date(Date.parse("Aug 04 2006 00:00:00 GMT-0500"));
Date d5=new Date(Date.parse("Aug 02 2006 06:00:00 GMT-0500"));
Date d6=new Date(Date.parse("Aug 02 2006 12:00:00 GMT-0500"));
//for hotzone of band #2
Date d7=new Date(Date.parse("Aug 01 2006 00:00:00 GMT-0500"));
Date d8=new Date(Date.parse("Sep 01 2006 00:00:00 GMT-0500"));
]]>
</zscript>
<timeline height="300px" width="100%">
<bandinfo width="70%" id="b1" intervalUnit="month"
intervalPixels="100" eventSourceUrl="data/example2.xml"
timeZone="${zone}" date="${current}">
<hotzone start="${d1}" end="${d2}" magnify="10" unit="week" />
<hotzone start="${d3}" end="${d4}" magnify="7" unit="day" />
<hotzone start="${d5}" end="${d6}" magnify="5" unit="hour" />
</bandinfo>
<bandinfo timeZone="${zone}" date="${current}"
width="30%" intervalUnit="year" intervalPixels="200"
syncWith="b1" eventSourceUrl="data/example2.xml"
trackHeight="0.5" trackGap="0.2" showEventText="false">
<hotzone start="${d7}" end="${d8}" magnify="20" unit="week" />
</bandinfo>
</timeline>
</window>
The resulting timeline below still needs a few more iteration of improvement to make it smooth. But I hope this has been a good starting point for you.
Using this ZK Timeline component is as easy as using other ZK components. You don't need to write javascript nor to know the AJAX details. In the next small talk I will demonstrate how to add and remove an OccurEvent dynamically, how to filter or highlight OccurEvent by using regular expressions, how to decorate the band , and how to use lazy-load feature in Timeline. See you later.

Gu Wei Xing is a software developer in NanTong of JiangSu province, China. He loves Java software development and Flash programming. He is also the host developer of the timeline project for ZK.forge.