Browse Source

lint timeline component (#3311)

revert-3409-performance
macleodbroad-wf 6 years ago
committed by Yotam Berkowitz
parent
commit
ca5662c6d5
9 changed files with 174 additions and 173 deletions
  1. +1
    -2
      lib/timeline/component/BackgroundGroup.js
  2. +1
    -1
      lib/timeline/component/Component.js
  3. +0
    -4
      lib/timeline/component/DataScale.js
  4. +0
    -1
      lib/timeline/component/GraphGroup.js
  5. +12
    -12
      lib/timeline/component/Group.js
  6. +134
    -128
      lib/timeline/component/ItemSet.js
  7. +2
    -2
      lib/timeline/component/Legend.js
  8. +18
    -18
      lib/timeline/component/LineGraph.js
  9. +6
    -5
      lib/timeline/component/TimeAxis.js

+ 1
- 2
lib/timeline/component/BackgroundGroup.js View File

@ -1,4 +1,3 @@
var util = require('../../util');
var Group = require('./Group');
/**
@ -25,7 +24,7 @@ BackgroundGroup.prototype = Object.create(Group.prototype);
* @param {boolean} [forceRestack=false] Force restacking of all items
* @return {boolean} Returns true if the group is resized
*/
BackgroundGroup.prototype.redraw = function(range, margin, forceRestack) {
BackgroundGroup.prototype.redraw = function(range, margin, forceRestack) { // eslint-disable-line no-unused-vars
var resized = false;
this.visibleItems = this._updateItemsInRange(this.orderedItems, this.visibleItems, range);

+ 1
- 1
lib/timeline/component/Component.js View File

@ -5,7 +5,7 @@ var util = require('../../util');
* @param {{dom: Object, domProps: Object, emitter: Emitter, range: Range}} [body]
* @param {Object} [options]
*/
function Component (body, options) {
function Component (body, options) { // eslint-disable-line no-unused-vars
this.options = null;
this.props = null;
}

+ 0
- 4
lib/timeline/component/DataScale.js View File

@ -1,6 +1,3 @@
/**
* Created by ludo on 25-1-16.
*/
function DataScale(start, end, autoScaleStart, autoScaleEnd, containerHeight, majorCharHeight, zeroAlign = false, formattingFunction=false) {
this.majorSteps = [1, 2, 5, 10];
@ -167,7 +164,6 @@ DataScale.prototype.followScale = function (other) {
}
//Get masters stats:
var lines = other.getLines();
var otherZero = other.convertValue(0);
var otherStep = other.getStep() * other.scale;

+ 0
- 1
lib/timeline/component/GraphGroup.js View File

@ -1,5 +1,4 @@
var util = require('../../util');
var DOMutil = require('../../DOMutil');
var Bars = require('./graph2d_types/bar');
var Lines = require('./graph2d_types/line');
var Points = require('./graph2d_types/points');

+ 12
- 12
lib/timeline/component/Group.js View File

@ -1,6 +1,5 @@
var util = require('../../util');
var stack = require('../Stack');
var RangeItem = require('./item/RangeItem');
/**
* @constructor Group
@ -157,8 +156,7 @@ Group.prototype.setData = function(data) {
}
} else if (this.nestedGroups) {
this.nestedGroups = null;
var collapsedDirClassName = this.itemSet.options.rtl ? 'collapsed-rtl' : 'collapsed'
collapsedDirClassName = this.itemSet.options.rtl ? 'collapsed-rtl' : 'collapsed'
util.removeClassName(this.dom.label, collapsedDirClassName);
util.removeClassName(this.dom.label, 'expanded');
util.removeClassName(this.dom.label, 'vis-nesting-group');
@ -290,7 +288,7 @@ Group.prototype.redraw = function(range, margin, forceRestack) {
var height = this._calculateHeight(margin);
// calculate actual size and position
var foreground = this.dom.foreground;
foreground = this.dom.foreground;
this.top = foreground.offsetTop;
this.right = foreground.offsetLeft;
this.width = foreground.offsetWidth;
@ -505,8 +503,9 @@ Group.prototype._updateSubgroupsSizes = function () {
Group.prototype.orderSubgroups = function() {
if (this.subgroupOrderer !== undefined) {
var sortArray = [];
var subgroup;
if (typeof this.subgroupOrderer == 'string') {
for (var subgroup in this.subgroups) {
for (subgroup in this.subgroups) {
sortArray.push({subgroup: subgroup, sortField: this.subgroups[subgroup].items[0].data[this.subgroupOrderer]})
}
sortArray.sort(function (a, b) {
@ -514,7 +513,7 @@ Group.prototype.orderSubgroups = function() {
})
}
else if (typeof this.subgroupOrderer == 'function') {
for (var subgroup in this.subgroups) {
for (subgroup in this.subgroups) {
sortArray.push(this.subgroups[subgroup].items[0].data);
}
sortArray.sort(this.subgroupOrderer);
@ -629,7 +628,7 @@ Group.prototype._updateItemsInRange = function(orderedItems, oldVisibleItems, ra
if (value < lowerBound) {return -1;}
else if (value <= upperBound) {return 0;}
else {return 1;}
}
};
// first check if the items that were in view previously are still in view.
// IMPORTANT: this handles the case for the items with startdate before the window and enddate after the window!
@ -667,7 +666,7 @@ Group.prototype._updateItemsInRange = function(orderedItems, oldVisibleItems, ra
}
// finally, we reposition all the visible items.
for (var i = 0; i < visibleItems.length; i++) {
for (i = 0; i < visibleItems.length; i++) {
var item = visibleItems[i];
if (!item.displayed) item.show();
// reposition item horizontally
@ -679,8 +678,9 @@ Group.prototype._updateItemsInRange = function(orderedItems, oldVisibleItems, ra
Group.prototype._traceVisible = function (initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
if (initialPos != -1) {
for (var i = initialPos; i >= 0; i--) {
var item = items[i];
var i, item;
for (i = initialPos; i >= 0; i--) {
item = items[i];
if (breakCondition(item)) {
break;
}
@ -692,8 +692,8 @@ Group.prototype._traceVisible = function (initialPos, items, visibleItems, visib
}
}
for (var i = initialPos + 1; i < items.length; i++) {
var item = items[i];
for (i = initialPos + 1; i < items.length; i++) {
item = items[i];
if (breakCondition(item)) {
break;
}

+ 134
- 128
lib/timeline/component/ItemSet.js View File

@ -35,10 +35,10 @@ function ItemSet(body, options) {
align: 'auto', // alignment of box items
stack: true,
stackSubgroups: true,
groupOrderSwap: function(fromGroup, toGroup, groups) {
var targetOrder = toGroup.order;
toGroup.order = fromGroup.order;
fromGroup.order = targetOrder;
groupOrderSwap: function(fromGroup, toGroup, groups) { // eslint-disable-line no-unused-vars
var targetOrder = toGroup.order;
toGroup.order = fromGroup.order;
fromGroup.order = targetOrder;
},
groupOrder: 'order',
@ -131,26 +131,26 @@ function ItemSet(body, options) {
// listeners for the DataSet of the items
this.itemListeners = {
'add': function (event, params, senderId) {
'add': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onAdd(params.items);
},
'update': function (event, params, senderId) {
'update': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onUpdate(params.items);
},
'remove': function (event, params, senderId) {
'remove': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onRemove(params.items);
}
};
// listeners for the DataSet of the groups
this.groupListeners = {
'add': function (event, params, senderId) {
'add': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onAddGroups(params.items);
},
'update': function (event, params, senderId) {
'update': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onUpdateGroups(params.items);
},
'remove': function (event, params, senderId) {
'remove': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onRemoveGroups(params.items);
}
};
@ -550,13 +550,14 @@ ItemSet.prototype.getSelection = function() {
*/
ItemSet.prototype.getVisibleItems = function() {
var range = this.body.range.getRange();
var right, left;
if (this.options.rtl) {
var right = this.body.util.toScreen(range.start);
var left = this.body.util.toScreen(range.end);
right = this.body.util.toScreen(range.start);
left = this.body.util.toScreen(range.end);
} else {
var left = this.body.util.toScreen(range.start);
var right = this.body.util.toScreen(range.end);
left = this.body.util.toScreen(range.start);
right = this.body.util.toScreen(range.end);
}
var ids = [];
@ -634,8 +635,8 @@ ItemSet.prototype.redraw = function() {
var visibleInterval = range.end - range.start;
var zoomed = (visibleInterval != this.lastVisibleInterval) || (this.props.width != this.props.lastWidth);
var scrolled = range.start != this.lastRangeStart;
var changedStackOption = options.stack != this.lastStack
var changedStackSubgroupsOption = options.stackSubgroups != this.lastStackSubgroups
var changedStackOption = options.stack != this.lastStack;
var changedStackSubgroupsOption = options.stackSubgroups != this.lastStackSubgroups;
var forceRestack = (zoomed || scrolled || changedStackOption || changedStackSubgroupsOption);
this.lastVisibleInterval = visibleInterval;
this.lastRangeStart = range.start;
@ -712,7 +713,6 @@ ItemSet.prototype._firstGroup = function() {
*/
ItemSet.prototype._updateUngrouped = function() {
var ungrouped = this.groups[UNGROUPED];
var background = this.groups[BACKGROUND];
var item, itemId;
if (this.groupsData) {
@ -866,7 +866,7 @@ ItemSet.prototype.setGroups = function(groups) {
groupsData.update(updatedNestedGroup);
})
}
})
});
// subscribe to new dataset
@ -903,8 +903,7 @@ ItemSet.prototype.getGroups = function() {
*/
ItemSet.prototype.removeItem = function(id) {
var item = this.itemsData.get(id),
dataset = this.itemsData.getDataSet(),
itemObj = this.items[id];
dataset = this.itemsData.getDataSet();
if (item) {
// confirm deletion
@ -1178,12 +1177,12 @@ ItemSet.prototype._orderNestedGroups = function(groupIds) {
},
order: this.options.groupOrder
});
var nestedGroupIds = nestedGroups.map(function(nestedGroup) { return nestedGroup.id })
var nestedGroupIds = nestedGroups.map(function(nestedGroup) { return nestedGroup.id });
newGroupIdsOrder = newGroupIdsOrder.concat(nestedGroupIds);
}
}, this)
}, this);
return newGroupIdsOrder;
}
};
/**
@ -1199,9 +1198,9 @@ ItemSet.prototype._addItem = function(item) {
var group = this.groups[groupId];
if (!group) {
item.groupShowing = false;
item.groupShowing = false;
} else if (group && group.data && group.data.showNested) {
item.groupShowing = true;
item.groupShowing = true;
}
if (group) group.add(item);
@ -1383,14 +1382,16 @@ ItemSet.prototype._onDragStart = function (event) {
* @private
*/
ItemSet.prototype._onDragStartAddItem = function (event) {
var xAbs;
var x;
var snap = this.options.snap || null;
if (this.options.rtl) {
var xAbs = util.getAbsoluteRight(this.dom.frame);
var x = xAbs - event.center.x + 10; // plus 10 to compensate for the drag starting as soon as you've moved 10px
xAbs = util.getAbsoluteRight(this.dom.frame);
x = xAbs - event.center.x + 10; // plus 10 to compensate for the drag starting as soon as you've moved 10px
} else {
var xAbs = util.getAbsoluteLeft(this.dom.frame);
var x = event.center.x - xAbs - 10; // minus 10 to compensate for the drag starting as soon as you've moved 10px
xAbs = util.getAbsoluteLeft(this.dom.frame);
x = event.center.x - xAbs - 10; // minus 10 to compensate for the drag starting as soon as you've moved 10px
}
var time = this.body.util.toTime(x);
@ -1446,11 +1447,12 @@ ItemSet.prototype._onDrag = function (event) {
var me = this;
var snap = this.options.snap || null;
var xOffset;
if (this.options.rtl) {
var xOffset = this.body.dom.root.offsetLeft + this.body.domProps.right.width;
xOffset = this.body.dom.root.offsetLeft + this.body.domProps.right.width;
} else {
var xOffset = this.body.dom.root.offsetLeft + this.body.domProps.left.width;
xOffset = this.body.dom.root.offsetLeft + this.body.domProps.left.width;
}
var scale = this.body.util.getScale();
@ -1477,11 +1479,16 @@ ItemSet.prototype._onDrag = function (event) {
this.touchParams.itemProps.forEach(function (props) {
var current = me.body.util.toTime(event.center.x - xOffset);
var initial = me.body.util.toTime(props.initialX - xOffset);
var offset;
var initialStart;
var initialEnd;
var start;
var end;
if (this.options.rtl) {
var offset = -(current - initial); // ms
offset = -(current - initial); // ms
} else {
var offset = (current - initial); // ms
offset = (current - initial); // ms
}
var itemData = this._cloneItemData(props.item.data); // clone the data
@ -1499,15 +1506,15 @@ ItemSet.prototype._onDrag = function (event) {
// drag left side of a range item
if (this.options.rtl) {
if (itemData.end != undefined) {
var initialEnd = util.convert(props.data.end, 'Date');
var end = new Date(initialEnd.valueOf() + offset);
initialEnd = util.convert(props.data.end, 'Date');
end = new Date(initialEnd.valueOf() + offset);
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
itemData.end = snap ? snap(end, scale, step) : end;
}
} else {
if (itemData.start != undefined) {
var initialStart = util.convert(props.data.start, 'Date');
var start = new Date(initialStart.valueOf() + offset);
initialStart = util.convert(props.data.start, 'Date');
start = new Date(initialStart.valueOf() + offset);
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
itemData.start = snap ? snap(start, scale, step) : start;
}
@ -1517,15 +1524,15 @@ ItemSet.prototype._onDrag = function (event) {
// drag right side of a range item
if (this.options.rtl) {
if (itemData.start != undefined) {
var initialStart = util.convert(props.data.start, 'Date');
var start = new Date(initialStart.valueOf() + offset);
initialStart = util.convert(props.data.start, 'Date');
start = new Date(initialStart.valueOf() + offset);
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
itemData.start = snap ? snap(start, scale, step) : start;
}
} else {
if (itemData.end != undefined) {
var initialEnd = util.convert(props.data.end, 'Date');
var end = new Date(initialEnd.valueOf() + offset);
initialEnd = util.convert(props.data.end, 'Date');
end = new Date(initialEnd.valueOf() + offset);
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
itemData.end = snap ? snap(end, scale, step) : end;
}
@ -1535,11 +1542,11 @@ ItemSet.prototype._onDrag = function (event) {
// drag both start and end
if (itemData.start != undefined) {
var initialStart = util.convert(props.data.start, 'Date').valueOf();
var start = new Date(initialStart + offset);
initialStart = util.convert(props.data.start, 'Date').valueOf();
start = new Date(initialStart + offset);
if (itemData.end != undefined) {
var initialEnd = util.convert(props.data.end, 'Date');
initialEnd = util.convert(props.data.end, 'Date');
var duration = initialEnd.valueOf() - initialStart.valueOf();
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
@ -1550,13 +1557,10 @@ ItemSet.prototype._onDrag = function (event) {
// TODO: pass a Moment instead of a Date to snap(). (Breaking change)
itemData.start = snap ? snap(start, scale, step) : start;
}
}
}
}
if (updateGroupAllowed && (!props.dragLeft && !props.dragRight) && newGroupBase!=null) {
if (itemData.group != undefined) {
var newOffset = newGroupBase - props.groupOffset;
@ -1677,10 +1681,10 @@ ItemSet.prototype._onGroupClick = function (event) {
util.addClassName(group.dom.label, 'expanded');
} else {
util.removeClassName(group.dom.label, 'expanded');
var collapsedDirClassName = this.options.rtl ? 'collapsed-rtl' : 'collapsed'
var collapsedDirClassName = this.options.rtl ? 'collapsed-rtl' : 'collapsed';
util.addClassName(group.dom.label, collapsedDirClassName);
}
}
};
ItemSet.prototype._onGroupDragStart = function (event) {
if (this.options.groupEditable.order) {
@ -1690,11 +1694,11 @@ ItemSet.prototype._onGroupDragStart = function (event) {
event.stopPropagation();
this.groupTouchParams.originalOrder = this.groupsData.getIds({
order: this.options.groupOrder
});
order: this.options.groupOrder
});
}
}
}
};
ItemSet.prototype._onGroupDrag = function (event) {
if (this.options.groupEditable.order && this.groupTouchParams.group) {
@ -1740,8 +1744,8 @@ ItemSet.prototype._onGroupDrag = function (event) {
// fetch current order of groups
var newOrder = groupsData.getIds({
order: this.options.groupOrder
});
order: this.options.groupOrder
});
// in case of changes since _onGroupDragStart
@ -1769,17 +1773,17 @@ ItemSet.prototype._onGroupDrag = function (event) {
// if dragged group was move upwards everything below should have an offset
if (newOrder[curPos+newOffset] == draggedId) {
newOffset = 1;
continue;
}
// if dragged group was move downwards everything above should have an offset
else if (origOrder[curPos+orgOffset] == draggedId) {
orgOffset = 1;
continue;
}
// found a group (apart from dragged group) that has the wrong position -> switch with the
// group at the position where other one should be, fix index arrays and continue
else {
var slippedPosition = newOrder.indexOf(origOrder[curPos+orgOffset])
var slippedPosition = newOrder.indexOf(origOrder[curPos+orgOffset]);
var switchGroup = groupsData.get(newOrder[curPos+newOffset]);
var shouldBeGroup = groupsData.get(origOrder[curPos+orgOffset]);
this.options.groupOrderSwap(switchGroup, shouldBeGroup, groupsData);
@ -1797,69 +1801,68 @@ ItemSet.prototype._onGroupDrag = function (event) {
}
}
}
};
ItemSet.prototype._onGroupDragEnd = function (event) {
if (this.options.groupEditable.order && this.groupTouchParams.group) {
event.stopPropagation();
if (this.options.groupEditable.order && this.groupTouchParams.group) {
event.stopPropagation();
// update existing group
var me = this;
var id = me.groupTouchParams.group.groupId;
var dataset = me.groupsData.getDataSet();
var groupData = util.extend({}, dataset.get(id)); // clone the data
me.options.onMoveGroup(groupData, function (groupData) {
if (groupData) {
// apply changes
groupData[dataset._fieldId] = id; // ensure the group contains its id (can be undefined)
dataset.update(groupData);
}
else {
// fetch current order of groups
var newOrder = dataset.getIds({
order: me.options.groupOrder
});
// restore original order
if (!util.equalArray(newOrder, me.groupTouchParams.originalOrder)) {
var origOrder = me.groupTouchParams.originalOrder;
var numGroups = Math.min(origOrder.length, newOrder.length);
var curPos = 0;
while (curPos < numGroups) {
// as long as the groups are where they should be step down along the groups order
while (curPos < numGroups && newOrder[curPos] == origOrder[curPos]) {
curPos++;
}
// all ok
if (curPos >= numGroups) {
break;
}
// found a group that has the wrong position -> switch with the
// group at the position where other one should be, fix index arrays and continue
var slippedPosition = newOrder.indexOf(origOrder[curPos])
var switchGroup = dataset.get(newOrder[curPos]);
var shouldBeGroup = dataset.get(origOrder[curPos]);
me.options.groupOrderSwap(switchGroup, shouldBeGroup, dataset);
dataset.update(switchGroup);
dataset.update(shouldBeGroup);
var switchGroupId = newOrder[curPos];
newOrder[curPos] = origOrder[curPos];
newOrder[slippedPosition] = switchGroupId;
curPos++;
}
}
// update existing group
var me = this;
var id = me.groupTouchParams.group.groupId;
var dataset = me.groupsData.getDataSet();
var groupData = util.extend({}, dataset.get(id)); // clone the data
me.options.onMoveGroup(groupData, function (groupData) {
if (groupData) {
// apply changes
groupData[dataset._fieldId] = id; // ensure the group contains its id (can be undefined)
dataset.update(groupData);
}
else {
}
// fetch current order of groups
var newOrder = dataset.getIds({
order: me.options.groupOrder
});
me.body.emitter.emit('groupDragged', { groupId: id });
}
}
// restore original order
if (!util.equalArray(newOrder, me.groupTouchParams.originalOrder)) {
var origOrder = me.groupTouchParams.originalOrder;
var numGroups = Math.min(origOrder.length, newOrder.length);
var curPos = 0;
while (curPos < numGroups) {
// as long as the groups are where they should be step down along the groups order
while (curPos < numGroups && newOrder[curPos] == origOrder[curPos]) {
curPos++;
}
// all ok
if (curPos >= numGroups) {
break;
}
// found a group that has the wrong position -> switch with the
// group at the position where other one should be, fix index arrays and continue
var slippedPosition = newOrder.indexOf(origOrder[curPos]);
var switchGroup = dataset.get(newOrder[curPos]);
var shouldBeGroup = dataset.get(origOrder[curPos]);
me.options.groupOrderSwap(switchGroup, shouldBeGroup, dataset);
dataset.update(switchGroup);
dataset.update(shouldBeGroup);
var switchGroupId = newOrder[curPos];
newOrder[curPos] = origOrder[curPos];
newOrder[slippedPosition] = switchGroupId;
curPos++;
}
}
}
});
me.body.emitter.emit('groupDragged', { groupId: id });
}
};
/**
* Handle selecting/deselecting an item when tapping it
@ -1984,7 +1987,7 @@ ItemSet.prototype._onMouseWheel = function(event) {
if (this.touchParams.itemIsDragging) {
this._onDragEnd(event);
}
}
};
/**
* Handle updates of an item on double tap
@ -2006,7 +2009,7 @@ ItemSet.prototype._onUpdateItem = function (item) {
}
});
}
}
};
/**
* Handle creation of an item on double tap
@ -2022,30 +2025,33 @@ ItemSet.prototype._onAddItem = function (event) {
var item = this.itemFromTarget(event);
if (!item) {
var xAbs;
var x;
// add item
if (this.options.rtl) {
var xAbs = util.getAbsoluteRight(this.dom.frame);
var x = xAbs - event.center.x;
xAbs = util.getAbsoluteRight(this.dom.frame);
x = xAbs - event.center.x;
} else {
var xAbs = util.getAbsoluteLeft(this.dom.frame);
var x = event.center.x - xAbs;
xAbs = util.getAbsoluteLeft(this.dom.frame);
x = event.center.x - xAbs;
}
// var xAbs = util.getAbsoluteLeft(this.dom.frame);
// var x = event.center.x - xAbs;
var start = this.body.util.toTime(x);
var scale = this.body.util.getScale();
var step = this.body.util.getStep();
var end;
var newItemData;
if (event.type == 'drop') {
newItemData = JSON.parse(event.dataTransfer.getData("text"))
newItemData.content = newItemData.content ? newItemData.content : 'new item'
newItemData.start = newItemData.start ? newItemData.start : (snap ? snap(start, scale, step) : start)
newItemData = JSON.parse(event.dataTransfer.getData("text"));
newItemData.content = newItemData.content ? newItemData.content : 'new item';
newItemData.start = newItemData.start ? newItemData.start : (snap ? snap(start, scale, step) : start);
newItemData.type = newItemData.type || 'box';
newItemData[this.itemsData._fieldId] = newItemData.id || util.randomUUID();
if (newItemData.type == 'range' && !newItemData.end) {
var end = this.body.util.toTime(x + this.props.width / 5);
end = this.body.util.toTime(x + this.props.width / 5);
newItemData.end = snap ? snap(end, scale, step) : end;
}
} else {
@ -2057,7 +2063,7 @@ ItemSet.prototype._onAddItem = function (event) {
// when default type is a range, add a default end date to the new item
if (this.options.type === 'range') {
var end = this.body.util.toTime(x + this.props.width / 5);
end = this.body.util.toTime(x + this.props.width / 5);
newItemData.end = snap ? snap(end, scale, step) : end;
}
}
@ -2103,7 +2109,7 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
if (shiftKey && this.options.multiselect) {
// select all items between the old selection and the tapped item
var itemGroup = this.itemsData.get(item.id).group;
// when filtering get the group of the last selected item
var lastSelectedGroup = undefined;
if (this.options.multiselectPerGroup) {
@ -2111,7 +2117,7 @@ ItemSet.prototype._onMultiSelectItem = function (event) {
lastSelectedGroup = this.itemsData.get(selection[0]).group;
}
}
// determine the selection range
if (!this.options.multiselectPerGroup || lastSelectedGroup == undefined || lastSelectedGroup == itemGroup) {
selection.push(item.id);

+ 2
- 2
lib/timeline/component/Legend.js View File

@ -173,8 +173,8 @@ Legend.prototype.redraw = function() {
}
var content = '';
for (var i = 0; i < groupArray.length; i++) {
var groupId = groupArray[i];
for (i = 0; i < groupArray.length; i++) {
groupId = groupArray[i];
if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) {
content += this.groups[groupId].content + '<br />';
}

+ 18
- 18
lib/timeline/component/LineGraph.js View File

@ -74,26 +74,26 @@ function LineGraph(body, options) {
// listeners for the DataSet of the items
this.itemListeners = {
'add': function (event, params, senderId) {
'add': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onAdd(params.items);
},
'update': function (event, params, senderId) {
'update': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onUpdate(params.items);
},
'remove': function (event, params, senderId) {
'remove': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onRemove(params.items);
}
};
// listeners for the DataSet of the groups
this.groupListeners = {
'add': function (event, params, senderId) {
'add': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onAddGroups(params.items);
},
'update': function (event, params, senderId) {
'update': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onUpdateGroups(params.items);
},
'remove': function (event, params, senderId) {
'remove': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onRemoveGroups(params.items);
}
};
@ -455,9 +455,9 @@ LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
//Pre-load arrays from existing groups if items are not changed (not in ids)
var existingItemsMap = {};
if (!groupIds && ids) {
for (var groupId in this.groups) {
for (groupId in this.groups) {
if (this.groups.hasOwnProperty(groupId)) {
var group = this.groups[groupId];
group = this.groups[groupId];
var existing_items = group.getItems();
groupsContent[groupId] = existing_items.filter(function (item) {
@ -474,9 +474,9 @@ LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
}
//Now insert data into the arrays.
for (var i = 0; i < items.length; i++) {
var item = items[i];
var groupId = item.group;
for (i = 0; i < items.length; i++) {
item = items[i];
groupId = item.group;
if (groupId === null || groupId === undefined) {
groupId = UNGROUPED;
}
@ -499,7 +499,7 @@ LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
}
//Make sure all groups are present, to allow removal of old groups
for (var groupId in this.groups){
for (groupId in this.groups){
if (this.groups.hasOwnProperty(groupId)){
if (!groupsContent.hasOwnProperty(groupId)) {
groupsContent[groupId] = new Array(0);
@ -508,7 +508,7 @@ LineGraph.prototype._updateAllGroupData = function (ids, groupIds) {
}
//Update legendas, style and axis
for (var groupId in groupsContent) {
for (groupId in groupsContent) {
if (groupsContent.hasOwnProperty(groupId)) {
if (groupsContent[groupId].length == 0) {
if (this.groups.hasOwnProperty(groupId)) {
@ -736,9 +736,9 @@ LineGraph.prototype._updateGraph = function () {
paths[groupIds[i]] = Lines.calcPath(groupsData[groupIds[i]], group);
}
Lines.draw(paths[groupIds[i]], group, this.framework);
//explicit no break;
// eslint-disable-line no-fallthrough
case "point":
//explicit no break;
// eslint-disable-line no-fallthrough
case "points":
if (group.options.style == "point" || group.options.style == "points" || group.options.drawPoints.enabled == true) {
Points.draw(groupsData[groupIds[i]], group, this.framework);
@ -746,7 +746,7 @@ LineGraph.prototype._updateGraph = function () {
break;
case "bar":
// bar needs to be drawn enmasse
//explicit no break
// eslint-disable-line no-fallthrough
default:
//do nothing...
}
@ -959,7 +959,7 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
}
// if there are items:
for (var i = 0; i < groupIds.length; i++) {
for (i = 0; i < groupIds.length; i++) {
if (groupRanges.hasOwnProperty(groupIds[i])) {
if (groupRanges[groupIds[i]].ignore !== true) {
minVal = groupRanges[groupIds[i]].min;
@ -1017,7 +1017,7 @@ LineGraph.prototype._updateYAxis = function (groupIds, groupRanges) {
// clean the accumulated lists
var tempGroups = ['__barStackLeft', '__barStackRight', '__lineStackLeft', '__lineStackRight'];
for (var i = 0; i < tempGroups.length; i++) {
for (i = 0; i < tempGroups.length; i++) {
if (groupIds.indexOf(tempGroups[i]) != -1) {
groupIds.splice(groupIds.indexOf(tempGroups[i]), 1);
}

+ 6
- 5
lib/timeline/component/TimeAxis.js View File

@ -222,11 +222,12 @@ TimeAxis.prototype._repaintLabels = function () {
dom.majorTexts = [];
dom.minorTexts = [];
var current;
var current; // eslint-disable-line no-unused-vars
var next;
var x;
var xNext;
var isMajor, nextIsMajor;
var isMajor;
var nextIsMajor; // eslint-disable-line no-unused-vars
var showMinorGrid;
var width = 0, prevWidth;
var line;
@ -345,7 +346,7 @@ TimeAxis.prototype._repaintMinorText = function (x, text, orientation, className
label.style.right = x + 'px';
} else {
label.style.left = x + 'px';
};
}
label.className = 'vis-text vis-minor ' + className;
//label.title = title; // TODO: this is a heavy operation
@ -383,7 +384,7 @@ TimeAxis.prototype._repaintMajorText = function (x, text, orientation, className
label.style.right = x + 'px';
} else {
label.style.left = x + 'px';
};
}
this.dom.majorTexts.push(label);
return label;
@ -423,7 +424,7 @@ TimeAxis.prototype._repaintMinorLine = function (x, width, orientation, classNam
} else {
line.style.left = (x - props.minorLineWidth / 2) + 'px';
line.className = 'vis-grid vis-vertical vis-minor ' + className;
};
}
line.style.width = width + 'px';

Loading…
Cancel
Save