Browse Source

Added convenience method `setData({groups: groups, items: items})`

flowchartTest
jos 9 years ago
parent
commit
7f8bedf580
3 changed files with 26 additions and 0 deletions
  1. +1
    -0
      HISTORY.md
  2. +11
    -0
      docs/timeline.html
  3. +14
    -0
      lib/timeline/Timeline.js

+ 1
- 0
HISTORY.md View File

@ -14,6 +14,7 @@ http://visjs.org
### Timeline
- Added method `setData({groups: groups, items: items})`.
- Fixed range items not being displayed smaller than 10 pixels (twice the
padding). In order to have overflowing text, one should now apply css style
`.vis.timeline .item.range { overflow: visible; }` instead of

+ 11
- 0
docs/timeline.html View File

@ -1003,6 +1003,17 @@ var options = {
</td>
</tr>
<tr>
<td>setData({<br>&nbsp;&nbsp;groups: groups,<br>&nbsp;&nbsp;items: items<br>})</td>
<td>none</td>
<td>Set both groups and items at once. Both properties are optional. This is a convenience method for individually calling both <code>setItems(items)</code> and <code>setGroups(groups)</code>.
Both <code>items</code> and <code>groups</code> can be an Array with Objects,
a DataSet, or a DataView. For each of the groups, the items of the
timeline are filtered on the property <code>group</code>, which
must correspond with the id of the group.
</td>
</tr>
<tr>
<td>setGroups(groups)</td>
<td>none</td>

+ 14
- 0
lib/timeline/Timeline.js View File

@ -207,6 +207,20 @@ Timeline.prototype.setGroups = function(groups) {
this.itemSet.setGroups(newDataSet);
};
/**
* Set both items and groups in one go
* @param {{items: Array | vis.DataSet | google.visualization.DataTable, groups: Array | vis.DataSet | google.visualization.DataTable}} data
*/
Timeline.prototype.setData = function (data) {
if (data && data.groups) {
this.setGroups(data.groups);
}
if (data && data.items) {
this.setItems(data.items);
}
};
/**
* Set selected items by their id. Replaces the current selection
* Unknown id's are silently ignored.

Loading…
Cancel
Save