Tooltip on item update time #2247
Changes from all commits
e26c2a4
44454ca
c1b47ef
0abe738
42f7501
cb96bb8
8650240
2942760
c2c482f
48e9dce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<html> | ||
<head> | ||
<title>Timeline | Tooltip on item onUpdateTime Option</title> | ||
|
||
<script src="../../../dist/vis.js"></script> | ||
<link href="../../../dist/vis.css" rel="stylesheet" type="text/css" /> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be nice to demonstrate also how to overwrite the tooltip style. e.g. with something simple like: .vis-item .vis-onUpdateTime-tooltip {
border-radius: 4px;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea! done |
||
<style type="text/css"> | ||
.vis-item .vis-onUpdateTime-tooltip { | ||
border-radius: 4px; | ||
} | ||
</style> | ||
|
||
<script src="../../googleAnalytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
|
||
<h1>Timeline Tooltip on item onUpdateTime Option</h1> | ||
|
||
<h2>With <code>tooltipOnItemUpdateTime: true</code> | ||
</h2> | ||
|
||
<div id="mytimeline1"></div> | ||
|
||
<h2>With <code>tooltipOnItemUpdateTime: { template: [Function] }</code> | ||
</h2> | ||
|
||
<div id="mytimeline2"></div> | ||
|
||
|
||
<h2>With groups</h2> | ||
|
||
<div id="mytimeline3"></div> | ||
<script> | ||
|
||
// create items | ||
var numberOfItems = 10; | ||
var items = new vis.DataSet(); | ||
var types = [ 'box', 'point', 'range'] | ||
|
||
|
||
for (var order = 0; order < numberOfItems; order++) { | ||
var date = vis.moment(); | ||
|
||
|
||
date.add(Math.round(Math.random() * 2), 'hour'); | ||
items.add({ | ||
id: order, | ||
type: types[Math.floor(3 * Math.random())], | ||
content: 'Item ' + order, | ||
start: date.clone().add(order + 1, 'hour'), | ||
end: date.clone().add(order + 3, 'hour') | ||
}); | ||
} | ||
|
||
// specify options | ||
var options = { | ||
multiselect: true, | ||
maxHeight: 400, | ||
start: new Date((new Date()).valueOf() - 10000000), | ||
end: new Date(1000*60*60*24 + (new Date()).valueOf()), | ||
editable: true | ||
}; | ||
|
||
var options1 = Object.assign({ | ||
tooltipOnItemUpdateTime: true | ||
}, options) | ||
var container1 = document.getElementById('mytimeline1'); | ||
timeline1 = new vis.Timeline(container1, items, null, options1); | ||
|
||
var options2 = Object.assign({ | ||
orientation: 'top', | ||
tooltipOnItemUpdateTime: { | ||
template: function(item) { | ||
return 'html template for tooltip with <b>item.start</b>: ' + item.start; | ||
} | ||
} | ||
}, options) | ||
var container2 = document.getElementById('mytimeline2'); | ||
timeline2 = new vis.Timeline(container2, items, null, options2); | ||
|
||
|
||
// create groups | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally would prefer a much more simple example without groups and stuff. Just something like the basicExample. |
||
var numberOfGroups = 25; | ||
var groups = new vis.DataSet() | ||
for (var i = 0; i < numberOfGroups; i++) { | ||
groups.add({ | ||
id: i, | ||
content: 'Truck ' + i | ||
}) | ||
} | ||
|
||
// create items for groups | ||
var numberOfItems = 1000; | ||
var itemsWithGroups = new vis.DataSet(); | ||
|
||
var itemsPerGroup = Math.round(numberOfItems/numberOfGroups); | ||
|
||
for (var truck = 0; truck < numberOfGroups; truck++) { | ||
var date = new Date(); | ||
for (var order = 0; order < itemsPerGroup; order++) { | ||
date.setHours(date.getHours() + 4 * (Math.random() < 0.2)); | ||
var start = new Date(date); | ||
|
||
date.setHours(date.getHours() + 2 + Math.floor(Math.random()*4)); | ||
var end = new Date(date); | ||
|
||
itemsWithGroups.add({ | ||
id: order + itemsPerGroup * truck, | ||
group: truck, | ||
start: start, | ||
end: end, | ||
content: 'Order ' + order | ||
}); | ||
} | ||
} | ||
|
||
|
||
var options3 = Object.assign({ | ||
orientation: 'top', | ||
tooltipOnItemUpdateTime: true | ||
}, options) | ||
var container3 = document.getElementById('mytimeline3'); | ||
timeline3 = new vis.Timeline(container3, itemsWithGroups, groups, options3); | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,17 @@ | |
padding: 5px; | ||
} | ||
|
||
.vis-item .vis-onUpdateTime-tooltip { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add .vis-item .vis-onUpdateTime-tooltip {
position: absolute;
color: white;
width: auto;
background: #4f81bd;
padding: 5px;
border-radius: 1px;
text-align: center;
white-space: nowrap;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
position: absolute; | ||
background: #4f81bd; | ||
color: white; | ||
width: 200px; | ||
text-align: center; | ||
white-space: nowrap; | ||
padding: 5px; | ||
border-radius: 1px; | ||
} | ||
|
||
.vis-item .vis-delete, .vis-item .vis-delete-rtl { | ||
position: absolute; | ||
top: 0px; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There already is a option
template
. Maybe we should call ittooltipTemplate
orhoverTemplate
or something like this? I'm not sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's in the
tooltipOnItemUpdateTime
so I don't think we need to change the name.