Reputation: 35
I'm using the Chap Links Timeline Library http://almende.github.io/chap-links-library/js/timeline/doc/ and find it very useful. However I need to stack the events in a special order.
I tried to use the customStackOrder() function without any success so far. How can I access custom data fields in this function?
My data elements look like:
data.push({
start: new Date( msg.timestamp ),
content: msg.text,
stackOrder: msg.level
});
and
function customStackOrder(A,B) {
return A.stackOrder - B.stackOrder
}
But A.stackOrder and B.stackOrder is undefined.
Upvotes: 0
Views: 428
Reputation: 6809
How can I access custom data fields in this function?
The Timeline does just ignores custom fields, and there is no easy way to access them. Usable item properties in the function customStackOrder
are the actual position and size (left
, right
, width
, height
) and timestamps (start
and optionally end
).
If you really want to do this, you will have to apply an inefficient hack. This is not officially supported and I don't recommend it:
var indexA = mytimeline.items.indexOf(itemA)
var dataA = data[indexA]
.var stackOrderA = dataA.stackOrder
Edit:
Another trick could be: if you don't use the field className
, you could misuse this to hold the value of your stackOrder
field. Just ensure the values cannot collide with some actual css.
Upvotes: 0