Hi FBuchinger,

No problem, I do something similar in my Timeline.

It sounds like the changes you want to make are to the events' attributes. You 
can also add or subtract events on the client side.

Here is the pseudo-code of what I do. All of the following would run on the 
client's browser, in Javascript:

1) Initiate an Ajax request. I use YAHOO.util.Connect.asyncRequest from the 
Yahoo library, but you could use the Simile Ajax library if you want.
json_url = The json url 

2) In the success callback, the function receives the data set from the server:
3) Either eval the data_set into a Javascript data structure, or use the Yahoo 
JSON read method. I use eval since my data set includes date objects, not date 
strings. (This is discussed on the Timeline wiki.) Using the date objects is a 
speed improvement but it means that the data set is not proper JSON, so it has 
to be eval'd. The result is an array of events. Each event is a hash.
4) Manipulate the event array. For example, I iterate through the event array, 
deleting some events. I also look at the labels for all of the events. If they 
are too long then I truncate them and append an ellipsis. The result of this 
step is an updated or new event array that is ready to be loaded into Timeline. 
Note that this step and the previous steps did not use the Timeline library at 
all.
timeline_data = the event array

Tip: do not use "event" as a variable name. It is a reserved word and breaks 
things in IE. Works fine in FF though. 

5) 
var    eventSource = new Timeline.DefaultEventSource();
create the band objects
create tl as the timeline object
eventSource.loadJSON(timeline_data, json_url)  // loads the array of events.
Note that the eventSource.loadJSON function does not make an ajax call to the 
server.
At this point, the Timeline will be showing your events.

Hope this helped.

Regards,

Larry





________________________________
From: jqueryui-vienna <[email protected]>
To: SIMILE Widgets <[email protected]>
Sent: Tuesday, December 23, 2008 4:57:10 AM
Subject: Preprocess JSON-Data in Timeline


I'm displaying different kinds of Events in one Timeline band - they
are distinguished their icon design and textcolor.
Right now I'm using eventSource.loadJSON() to fetch the JSON data. The
downside: all layout parameters (icon paths, colors) are hardcoded in
the JSON feed. This makes it difficult to change the appereance of the
events on the clientside.

So I'm looking for a way to preprocess the received JSON data (e.g.
set icon/text color based on event category). Note: the timeline
doesn't have a fixed set of events, it constantly receives new events.
The JSON preprocess approach should support this scenario.

Any ideas?



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to