|
|
@ -218,6 +218,8 @@ Timeline.prototype.setItems = function(items) { |
|
|
|
this.setWindow(start, end, {animation: false}); |
|
|
|
} |
|
|
|
else { |
|
|
|
// call fit twice as
|
|
|
|
this.fit({animation: false}); |
|
|
|
this.fit({animation: false}); |
|
|
|
} |
|
|
|
} |
|
|
@ -350,32 +352,37 @@ Timeline.prototype.focus = function(id, options) { |
|
|
|
* When no maximum is found, max==null |
|
|
|
*/ |
|
|
|
Timeline.prototype.getItemRange = function() { |
|
|
|
// calculate min from start filed
|
|
|
|
var dataset = this.itemsData && this.itemsData.getDataSet(); |
|
|
|
var min = null; |
|
|
|
var max = null; |
|
|
|
var minId = null; |
|
|
|
var maxId = null; |
|
|
|
|
|
|
|
var dataset = this.itemsData && this.itemsData.getDataSet(); |
|
|
|
if (dataset) { |
|
|
|
// calculate the minimum value of the field 'start'
|
|
|
|
var minItem = dataset.min('start'); |
|
|
|
min = minItem ? util.convert(minItem.start, 'Date').valueOf() : null; |
|
|
|
// Note: we convert first to Date and then to number because else
|
|
|
|
// a conversion from ISODate to Number will fail
|
|
|
|
|
|
|
|
// calculate maximum value of fields 'start' and 'end'
|
|
|
|
var maxStartItem = dataset.max('start'); |
|
|
|
if (maxStartItem) { |
|
|
|
max = util.convert(maxStartItem.start, 'Date').valueOf(); |
|
|
|
} |
|
|
|
var maxEndItem = dataset.max('end'); |
|
|
|
if (maxEndItem) { |
|
|
|
if (max == null) { |
|
|
|
max = util.convert(maxEndItem.end, 'Date').valueOf(); |
|
|
|
var fieldId = dataset._fieldId; |
|
|
|
|
|
|
|
dataset.forEach(function (item) { |
|
|
|
var start = util.convert(item.start, 'Date').valueOf(); |
|
|
|
var end = util.convert(item.end != undefined ? item.end : item.start, 'Date').valueOf(); |
|
|
|
if (min === null || start < min) { |
|
|
|
min = start; |
|
|
|
minId = item[fieldId]; |
|
|
|
} |
|
|
|
else { |
|
|
|
max = Math.max(max, util.convert(maxEndItem.end, 'Date').valueOf()); |
|
|
|
if (max === null || end > max) { |
|
|
|
max = start; |
|
|
|
maxId = item[fieldId]; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
var minItem = this.itemSet.items[minId]; |
|
|
|
var maxItem = this.itemSet.items[maxId]; |
|
|
|
if (minItem && minItem.width && maxItem && maxItem.width) { |
|
|
|
var left = minItem.left; |
|
|
|
var right = maxItem.left + maxItem.width; |
|
|
|
|
|
|
|
min = this._toTime(left - 10); |
|
|
|
max = this._toTime(right + 10); |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|