Contents: Creating mashups : Mashup Center 2.0
widget displays a set of chronological events in a timeline. The event data can come from another widget on the mashup page, an Atom or RSS feed, or a file that contains data in comma-separated value (CSV) format.
You can populate the Timeline
widget with events in the following ways:
- Create an RSS or Atom feed in the catalog, add it to the mashup builder, and then drag it onto the Timeline widget to generate an automatic wire.
- Configure the Timeline widget settings directly with the URL of a file that contains data in CSV format in the Data Source URL field.
- Configure the Timeline widget settings directly with the URL of an RSS or Atom feed in the Data Source URL field, for example http://rssfeeds.usatoday.com/usatoday-NewsTopStories.
In view mode, by default, the events are displayed as dots and bars along a horizontal axis. The widget displays two bands of the same timeline. The main (top) band typically has a shorter interval than the secondary (bottom) band. For example, you can configure the top band to display events in days and the bottom band to display events in months. You can also hide the secondary band and display only one band. Using the buttons at the bottom of each band, you can zoom the time interval in and out, step through each event one by one, and jump to the first or last event.
When you display events in a timeline in the Timeline
widget, you can hover your cursor over a particular event and see a description of the event.
When configuring the Timeline
widget, use the following tips:
- If you want the Timeline widget to display data from a feed or a CSV file, add the URL to the Data Source URL field. By default, the widget displays data from a sample TXT file called example.txt. The CSV text format is defined by dojo CsvStore and documented on the Dojo Toolkit Web site . The column names go in the first row of data. Cell values are comma-separated, and any cell value containing a comma should be double-quoted, for example "Caine Mutiny, The". Cell values containing double quotes should also be double-quoted, and the interior double-quotes should be doubled, for example "The Sequel to ""Dances With Wolves""".
- Select the type of interval you want to display in both the main and secondary bands. You can select seconds, minutes, hours, days, weeks, months, years, decades, centuries, and even millenniums. To hide the secondary band, clear the Show secondary band check box.
- Use the following tips when filling in the element fields:
- Modify the start and end dates as needed in the Start date element name and End date element name fields. The element name is the name of the feed element, data item, or table column name that contains either the start or end date. Examples of these values include gd:when.startTime and gd:when.endTime. The Timeline widget can parse dates in many formats, including some locale-specific formats, but we recommend the following international date format: 2009-02-12 16:40:03 EST. Here is another common international date format that you can use: 2009-01-29T16:40:03Z and 2009-01-18T16:40:03+00:00.
- Modify the event title as needed in the Title element name field. The element name is the name of the feed element, data item, or table column name. An example value for this field is title.
- Modify the event description as needed in the Description element name field. The element name is the name of the feed element, data item, or table column name that contains the event description. Example values for this field are content and description.
- Modify the event category as needed in the Category element name field. The element name is the name of the feed element, data item, or table column name that contains the event description. An example value for this field is category. The category is optionally used to control the color of the event, with the default being '1' for blue. Other predefined categories and colors are '2' for red, '3' for green, '4' for orange, and '5' for purple. If you have access to the server on which the Timeline widget WAR file is installed, you can add or modify category colors by doing the following steps:
To see which elements are available to use, load the feed URL in your browser and view the page source. If the feed is an Atom feed, you can reference elements within the entry tag. If the feed is an RSS feed, you can reference elements within the item tag. For more information about the element fields, see the readme file located in Mashups_install_root\mm\installedApps\timeline.ear.ear\timeline.war.
- Edit or add the image files in \Timeline\images: event-n.png, event-extended-left-n.png, and event-extended-right-n.png, where n is the category number for that color.
- Edit or add the style classes in \Timeline\timeLine.css: timeline-event-extended-middle-n, where n is the category number for that color.
To add new events from other widgets to an existing timeline, select the Add events to existing ones check box. If this check box is not selected (the default), the content of the timeline gets replaced when events are received from another widget.
See the following table to learn which events the Timeline
widget can send and receive:
Table 1. Timeline events
|Select Event as Table: when clicking on or activating an event, sends event data as table.||Accept Feed URL using URL: receives event from a feed URL.|
|Title as Text: when clicking on or activating an event, sends event title as text.||Accept Data using Any Data: receives event in any format, for example a table, text, object, or array.|
|Description as Text: when clicking on or activating an event, sends event description as text.||Center to Date using Timestamp: receives a timestamp to center the timeline on. The timestamp format is YYYY-MM-DD HH:MM:SS, for example 2009-05-21 19:00:00.|
|Start Date as Timestamp: when clicking on or activating an event, sends event start date as timestamp, for example 2009-05-21 19:00:00.|
|End Date as Timestamp: when clicking on or activating an event, sends event end date as timestamp, for example 2009-05-21 23:59:59.|
|Category as Number: when clicking on or activating an event, sends event category as number.|
: Display a feed timeline by specifying a feed URL in the Timeline
widget configuration settings.
- Hover your cursor over the Timeline widget, click the menu options icon , and select Edit Settings.
- In the configuration window, in the Data Source URL field, type the URL of the feed, for example http://eventful.com/atom/events/?q=&location_type=metro_id&location_id=8&l=Boston+metro+area&sort_order=Popularity.
- Leave the default values in the Main band interval and Secondary band interval fields.
- In the Start date element name field, replace the default value with gd:when.startTime.
Note: To see which elements are available to use when configuring additional Timeline widgets, load the feed URL in your browser and view the page source. If the feed is an Atom feed, you can reference elements within the entry tag. If the feed is an RSS feed, you can reference elements within the item tag.
- In the End date element name field, replace the default value with gd:when.endTime.
- In the Title element name field, replace the default value with title.
- In the Description element name field, replace the default value with content.
- Click Save.
Now the Timeline
widget displays the chronological event data from the feed.
Parent topic: Widget reference : Mashup Center 2.0