diff --git a/HISTORY.md b/HISTORY.md
index 631e7b95..44bafa2a 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -10,6 +10,7 @@ http://visjs.org
- Implemented options `selectable`, `editable`.
- Added events when dragging the custom time bar.
- Multiple items can be selected using ctrl+click or shift+click.
+- Implemented functions `setWindow(start, end)` and `getWindow()`.
### DataSet
diff --git a/docs/timeline.html b/docs/timeline.html
index 9b1674c6..af328bde 100644
--- a/docs/timeline.html
+++ b/docs/timeline.html
@@ -599,10 +599,16 @@ var options = {
| getSelection() |
- ids |
+ Number[] |
Get an array with the ids of the currently selected items. |
+
+ | getWindow() |
+ Object |
+ Get the current visible window. Returns an object with properties start: Date and end: Date. |
+
+
| on(event, callback) |
none |
@@ -649,6 +655,12 @@ var options = {
+
+ | setWindow(start, end) |
+ none |
+ Set the current visible window. The parameters start and end can be a Date, Number, or String. If the parameter value of start or end is null, the parameter will be left unchanged. |
+
+
diff --git a/src/timeline/Timeline.js b/src/timeline/Timeline.js
index 4d7d20b8..497bd54e 100644
--- a/src/timeline/Timeline.js
+++ b/src/timeline/Timeline.js
@@ -432,6 +432,28 @@ Timeline.prototype.getSelection = function getSelection() {
return this.content ? this.content.getSelection() : [];
};
+/**
+ * Set the visible window. Both parameters are optional, you can change only
+ * start or only end.
+ * @param {Date | Number | String} [start] Start date of visible window
+ * @param {Date | Number | String} [end] End date of visible window
+ */
+Timeline.prototype.setWindow = function setWindow(start, end) {
+ this.range.setRange(start, end);
+};
+
+/**
+ * Get the visible window
+ * @return {{start: Date, end: Date}} Visible range
+ */
+Timeline.prototype.getWindow = function setWindow() {
+ var range = this.range.getRange();
+ return {
+ start: new Date(range.start),
+ end: new Date(range.end)
+ };
+};
+
/**
* Handle selecting/deselecting an item when tapping it
* @param {Event} event