|
|
@ -4,7 +4,7 @@ |
|
|
|
* |
|
|
|
* A dynamic, browser-based visualization library. |
|
|
|
* |
|
|
|
* @version 0.7.5-SNAPSHOT |
|
|
|
* @version 1.0.0 |
|
|
|
* @date 2014-05-02 |
|
|
|
* |
|
|
|
* @license |
|
|
@ -1742,7 +1742,6 @@ DataSet.prototype.getIds = function (options) { |
|
|
|
|
|
|
|
/** |
|
|
|
* Execute a callback function for every item in the dataset. |
|
|
|
* The order of the items is not determined. |
|
|
|
* @param {function} callback |
|
|
|
* @param {Object} [options] Available options: |
|
|
|
* {Object.<String, String>} [convert] |
|
|
@ -1988,9 +1987,8 @@ DataSet.prototype.min = function (field) { |
|
|
|
/** |
|
|
|
* Find all distinct values of a specified field |
|
|
|
* @param {String} field |
|
|
|
* @return {Array} values Array containing all distinct values. If the data |
|
|
|
* items do not contain the specified field, an array |
|
|
|
* containing a single value undefined is returned. |
|
|
|
* @return {Array} values Array containing all distinct values. If data items |
|
|
|
* do not contain the specified field are ignored. |
|
|
|
* The returned array is unordered. |
|
|
|
*/ |
|
|
|
DataSet.prototype.distinct = function (field) { |
|
|
@ -2010,7 +2008,7 @@ DataSet.prototype.distinct = function (field) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!exists) { |
|
|
|
if (!exists && (value !== undefined)) { |
|
|
|
values[count] = value; |
|
|
|
count++; |
|
|
|
} |
|
|
@ -7551,47 +7549,12 @@ Timeline.prototype.setItems = function(items) { |
|
|
|
this.itemSet.setItems(newDataSet); |
|
|
|
|
|
|
|
if (initialLoad && (this.options.start == undefined || this.options.end == undefined)) { |
|
|
|
// apply the data range as range
|
|
|
|
var dataRange = this.getItemRange(); |
|
|
|
this.fit(); |
|
|
|
|
|
|
|
// add 5% space on both sides
|
|
|
|
var start = dataRange.min; |
|
|
|
var end = dataRange.max; |
|
|
|
if (start != null && end != null) { |
|
|
|
var interval = (end.valueOf() - start.valueOf()); |
|
|
|
if (interval <= 0) { |
|
|
|
// prevent an empty interval
|
|
|
|
interval = 24 * 60 * 60 * 1000; // 1 day
|
|
|
|
} |
|
|
|
start = new Date(start.valueOf() - interval * 0.05); |
|
|
|
end = new Date(end.valueOf() + interval * 0.05); |
|
|
|
} |
|
|
|
|
|
|
|
// override specified start and/or end date
|
|
|
|
if (this.options.start != undefined) { |
|
|
|
start = util.convert(this.options.start, 'Date'); |
|
|
|
} |
|
|
|
if (this.options.end != undefined) { |
|
|
|
end = util.convert(this.options.end, 'Date'); |
|
|
|
} |
|
|
|
|
|
|
|
// skip range set if there is no start and end date
|
|
|
|
if (start === null && end === null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// if start and end dates are set but cannot be satisfyed due to zoom restrictions — correct end date
|
|
|
|
if (start != null && end != null) { |
|
|
|
var diff = end.valueOf() - start.valueOf(); |
|
|
|
if (this.options.zoomMax != undefined && this.options.zoomMax < diff) { |
|
|
|
end = new Date(start.valueOf() + this.options.zoomMax); |
|
|
|
} |
|
|
|
if (this.options.zoomMin != undefined && this.options.zoomMin > diff) { |
|
|
|
end = new Date(start.valueOf() + this.options.zoomMin); |
|
|
|
} |
|
|
|
} |
|
|
|
var start = (this.options.start != undefined) ? util.convert(this.options.start, 'Date') : null; |
|
|
|
var end = (this.options.end != undefined) ? util.convert(this.options.end, 'Date') : null; |
|
|
|
|
|
|
|
this.range.setRange(start, end); |
|
|
|
this.setWindow(start, end); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -7599,7 +7562,7 @@ Timeline.prototype.setItems = function(items) { |
|
|
|
* Set groups |
|
|
|
* @param {vis.DataSet | Array | google.visualization.DataTable} groups |
|
|
|
*/ |
|
|
|
Timeline.prototype.setGroups = function(groups) { |
|
|
|
Timeline.prototype.setGroups = function setGroups(groups) { |
|
|
|
// convert to type DataSet when needed
|
|
|
|
var newDataSet; |
|
|
|
if (!groups) { |
|
|
@ -7617,6 +7580,34 @@ Timeline.prototype.setGroups = function(groups) { |
|
|
|
this.itemSet.setGroups(newDataSet); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Set Timeline window such that it fits all items |
|
|
|
*/ |
|
|
|
Timeline.prototype.fit = function fit() { |
|
|
|
// apply the data range as range
|
|
|
|
var dataRange = this.getItemRange(); |
|
|
|
|
|
|
|
// add 5% space on both sides
|
|
|
|
var start = dataRange.min; |
|
|
|
var end = dataRange.max; |
|
|
|
if (start != null && end != null) { |
|
|
|
var interval = (end.valueOf() - start.valueOf()); |
|
|
|
if (interval <= 0) { |
|
|
|
// prevent an empty interval
|
|
|
|
interval = 24 * 60 * 60 * 1000; // 1 day
|
|
|
|
} |
|
|
|
start = new Date(start.valueOf() - interval * 0.05); |
|
|
|
end = new Date(end.valueOf() + interval * 0.05); |
|
|
|
} |
|
|
|
|
|
|
|
// skip range set if there is no start and end date
|
|
|
|
if (start === null && end === null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.range.setRange(start, end); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* Get the data range of the item set. |
|
|
|
* @returns {{min: Date, max: Date}} range A range with a start and end Date. |
|
|
|