diff --git a/HISTORY.md b/HISTORY.md
index d96954e8..323d3d57 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -21,7 +21,8 @@ http://visjs.org
individual items.
- Fixed height of BackgroundItems not being 100% when timeline has a fixed height.
- Fixed width of BackgroundItems not being reduced to 0 when zooming out.
-- Fixed onclick events in items not working.
+- Fixed onclick events in items not working.
+- Added hiddenDates to hide specific times and/or days in the timeline.
### DataSet
diff --git a/dist/vis.js b/dist/vis.js
index 80cac987..33071695 100644
--- a/dist/vis.js
+++ b/dist/vis.js
@@ -12575,13 +12575,13 @@ return /******/ (function(modules) { // webpackBootstrap
* @param Core
*/
exports.convertHiddenOptions = function(body, hiddenDates) {
- var hiddenTimes = hiddenDates.specific;
- if (hiddenTimes) {
- if (Array.isArray(hiddenTimes) == true) {
- for (var i = 0; i < hiddenTimes.length; i++) {
+ var specificHiddenDates = hiddenDates.specific;
+ if (specificHiddenDates) {
+ if (Array.isArray(specificHiddenDates) == true) {
+ for (var i = 0; i < specificHiddenDates.length; i++) {
var dateItem = {};
- dateItem.start = moment(hiddenTimes[i].start).toDate().valueOf();
- dateItem.end = moment(hiddenTimes[i].end).toDate().valueOf();
+ dateItem.start = moment(specificHiddenDates[i].start).toDate().valueOf();
+ dateItem.end = moment(specificHiddenDates[i].end).toDate().valueOf();
body.hiddenDates.push(dateItem);
}
body.hiddenDates.sort(function (a, b) {
@@ -12590,12 +12590,26 @@ return /******/ (function(modules) { // webpackBootstrap
}
else {
body.hiddenDates = [{
- start: moment(hiddenTimes.start).toDate().valueOf(),
- end: moment(hiddenTimes.end).toDate().valueOf()
+ start: moment(specificHiddenDates.start).toDate().valueOf(),
+ end: moment(specificHiddenDates.end).toDate().valueOf()
}
];
}
}
+
+ var periodicHiddenDates = hiddenDates.periodic;
+ if (periodicHiddenDates) {
+ if (periodicHiddenDates.times) {
+ if (Array.isArray(periodicHiddenDates.times) != true) {
+ periodicHiddenDates.times = [periodicHiddenDates.times];
+ }
+ }
+ if (periodicHiddenDates.days) {
+ if (Array.isArray(periodicHiddenDates.days) != true) {
+ periodicHiddenDates.days = [periodicHiddenDates.days];
+ }
+ }
+ }
};
exports.updateHiddenDates = function (body, hiddenDates) {
diff --git a/docs/timeline.html b/docs/timeline.html
index ef1c57ca..38fc5dd0 100644
--- a/docs/timeline.html
+++ b/docs/timeline.html
@@ -479,6 +479,45 @@ var options = {
+
+ | hiddenDates |
+ Object |
+ none |
+ This option allows you to hide specific timespans from the time axis. For usage, look at the object definitions below.
+ |
+
+
+ | hiddenDates.specific |
+ Array | Object |
+ none |
+ The specific hiddenDates are manually, fully defined dates that will be hidden from the timeline. The dates can be supplied as an object:
+ {start: '2014-03-21 00:00:00', end: '2014-03-28 00:00:00'} or as an Array of these objects.
+ |
+
+
+ | hiddenDates.periodic |
+ Object |
+ none |
+ This option can be used to specify recurring days and times that have to be hidden from view (weekends, working hours etc.).
+ |
+
+
+ | hiddenDates.periodic.times |
+ Array | Object |
+ none |
+ You can manually specify times which will then be hidden every day on the timeline. These are defined as an object: {start:'20:00:00', end:'09:00:00'}
+ or as an Array of these objects.
+ |
+
+
+ | hiddenDates.periodic.days |
+ Array | Object |
+ none |
+ You can manually specify days which will then be hidden every week on the timeline. These are defined as an object: {start:6, end:1}
+ or as an Array of these objects. 1 stands for Monday and 7 stands for Sunday. So: {start:6, end:1} means hide Saturday and Sunday.
+ |
+
+
| locale |
String |
diff --git a/examples/timeline/hiding_times.html b/examples/timeline/29_hiding_times.html
similarity index 100%
rename from examples/timeline/hiding_times.html
rename to examples/timeline/29_hiding_times.html
diff --git a/lib/timeline/DateUtil.js b/lib/timeline/DateUtil.js
index eefef9a0..2e9a13e6 100644
--- a/lib/timeline/DateUtil.js
+++ b/lib/timeline/DateUtil.js
@@ -10,13 +10,13 @@ var moment = require('../module/moment');
* @param Core
*/
exports.convertHiddenOptions = function(body, hiddenDates) {
- var hiddenTimes = hiddenDates.specific;
- if (hiddenTimes) {
- if (Array.isArray(hiddenTimes) == true) {
- for (var i = 0; i < hiddenTimes.length; i++) {
+ var specificHiddenDates = hiddenDates.specific;
+ if (specificHiddenDates) {
+ if (Array.isArray(specificHiddenDates) == true) {
+ for (var i = 0; i < specificHiddenDates.length; i++) {
var dateItem = {};
- dateItem.start = moment(hiddenTimes[i].start).toDate().valueOf();
- dateItem.end = moment(hiddenTimes[i].end).toDate().valueOf();
+ dateItem.start = moment(specificHiddenDates[i].start).toDate().valueOf();
+ dateItem.end = moment(specificHiddenDates[i].end).toDate().valueOf();
body.hiddenDates.push(dateItem);
}
body.hiddenDates.sort(function (a, b) {
@@ -25,12 +25,26 @@ exports.convertHiddenOptions = function(body, hiddenDates) {
}
else {
body.hiddenDates = [{
- start: moment(hiddenTimes.start).toDate().valueOf(),
- end: moment(hiddenTimes.end).toDate().valueOf()
+ start: moment(specificHiddenDates.start).toDate().valueOf(),
+ end: moment(specificHiddenDates.end).toDate().valueOf()
}
];
}
}
+
+ var periodicHiddenDates = hiddenDates.periodic;
+ if (periodicHiddenDates) {
+ if (periodicHiddenDates.times) {
+ if (Array.isArray(periodicHiddenDates.times) != true) {
+ periodicHiddenDates.times = [periodicHiddenDates.times];
+ }
+ }
+ if (periodicHiddenDates.days) {
+ if (Array.isArray(periodicHiddenDates.days) != true) {
+ periodicHiddenDates.days = [periodicHiddenDates.days];
+ }
+ }
+ }
};
exports.updateHiddenDates = function (body, hiddenDates) {