almende / chap-links-library

a web based visualization library for displaying graphs, networks, and timelines
http://almende.github.com/chap-links-library
Apache License 2.0
599 stars 167 forks source link

getCluster(), getClusterIndex() and getSelection() with cluster selection info #308

Closed igui closed 10 years ago

igui commented 10 years ago

This PR adds the ability to get a cluster information in the same way you call to getItem(). For example you can get every item contained within the selected cluster. A call to getCluster() yields an Object with the cluster position within the timeline on the start attribute and each item info on the item array. Each item contains the same information as in a call to getItem(). For example if you have a cluster with two events the result will be similar to.

{
    "start": "2014-06-23T21:00:00.000Z",
    "type": "box",
    "items": [
      {
        "content": "Event 1",
        "start": "2014-06-23T03:00:00.000Z",
        "type": "box"
      },
      {
        "content": "Event 2",
        "start": "2014-06-24T03:00:00.000Z",
        "type": "box"
      },
    ]
}

Also you can get 'select' events when the user clicks on a cluster (I didn't added support for adding the CSS class timeline-event-selected to a selected cluster) but can be added rather easy in the selectCluster() function.

Finally I added some documentation to the added functions :)

Best! Igui

josdejong commented 10 years ago

Thanks