Thanks a lot Mike, adding a decorator works now great!
I have some problem removing the decorator and a few new questions in this 
context:

1. You set an ID attribute while initializing the SpanHighlightDecorator. This 
is a good idea (I need this id for removing exactly this decorator). I have 
looked into the source-code (decorators.js) and there isn't an id-attribute 
defined. Can i modify (adding) this id-param from extern without changing the 
source-code of the timeline? (Sorry, I'm a Javascript newbie..)

2. In your proposed removing function the this._decorators[index].remove(); 
doesn't work for me, the _decorator object has no method remove(). The splice 
works, but the decorator doesn't disappear in the timeline.

3. How difficult is it to set an label to the center of a decorator? I don't 
need a start and end label, but an "description" for the highlighted area.

Clemens

Am 09.11.2010 um 17:55 schrieb Michael Nosal:

> Clemens,
> Yes, it is possible (and easy) to add/remove decorators dynamically. I needed 
> to do exactly this.
> 
> The decorators for a band are stored in an array in the band. We just need a 
> function to add them:
> 
> Timeline._Band.prototype.addDecorator = function(decorator) {
>       this._decorators.push(decorator);
>       decorator.initialize(this,this._timeline);
>       decorator.paint();
> }
> 
> Create a new decorator and add to the desired band:
> 
> var band = tl.getBand(1);
> var theme = Timeline.ClassicTheme.create();
> band.addDecorator(new Timeline.SpanHighlightDecorator({
>       id:"my_decorator_id",
>       startDate: decorator_start_date,
>       endDate: decorator_end_date,
>       startLabel:"Start",
>       endLabel:"End",
>       theme:theme
> }));
> 
> Then your decorator should show up on your timeline.
> 
> Removing is easy too:
> 
> Timeline._Band.prototype.removeDecorator = function(index) {
>       this._decorators[index].remove();
>       this._decorators.splice(index,1);
> }
> 
> 
> --Mike
> 
> On Nov 9, 2010, at 9:05 AM, einsA wrote:
> 
>> Hello list,
>> 
>> is it possible to change (add/remove) some decorators to the bands
>> dynamically - during runtime?
>> I initialize the timeline on page load once and then inject/remove new
>> data via json. Therefore it would be great not only to add/remove
>> events but decorators too. I've tried to add the decorators and then
>> calling the paint() methods of the timeline and the bands, but the new
>> decorators doesn't appear.
>> 
>> I hope you understand my wish and anybody can help me.
>> 
>> Gruß
>> Clemens
> 
> -- 
> 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.
> 

-- 
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