-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(timeline): add an option to make the custom marker editable (#117)
* feat(timeline): add an option to make the custom marker editable (#105) * chore(docs): update the timeline document (#105) * chore(docs): add new example of custom time markers (#105) * chore(docs): add new example of editable custom time markers (#105) * chore(docs): add the links to the example overview (#105) * fix(docs): don't use foo and bar (#105)
- Loading branch information
1 parent
efa4093
commit 46ea275
Showing
6 changed files
with
110 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Timeline | Markers example</title> | ||
|
||
<style type="text/css"> | ||
body, html { | ||
font-family: sans-serif; | ||
font-size: 11pt; | ||
} | ||
</style> | ||
|
||
<script src="../../../dist/vis-timeline-graph2d.min.js"></script> | ||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" /> | ||
|
||
</head> | ||
<body> | ||
|
||
<p>The Timeline has a function to add multiple custom time markers which can be dragged by the user.</p> | ||
<p>In this example, you can add new markers by double-clicking the timeline below and delete the markers by double-clicking it.</p> | ||
<p> | ||
<input type="text" id="markerText" placeholder="marker text"> | ||
</p> | ||
|
||
<div id="visualization"></div> | ||
|
||
<script type="text/javascript"> | ||
var container = document.getElementById('visualization'); | ||
var items = new vis.DataSet(); | ||
var customDate = new Date(); | ||
var options = { | ||
start: new Date(Date.now() - 1000 * 60 * 60 * 24), | ||
end: new Date(Date.now() + 1000 * 60 * 60 * 24 * 6) | ||
}; | ||
var timeline = new vis.Timeline(container, items, options); | ||
|
||
timeline.on('doubleClick', function (properties) { | ||
var eventProps = timeline.getEventProperties(properties.event); | ||
if (eventProps.what === 'custom-time') { | ||
timeline.removeCustomTime(eventProps.customTime); | ||
} else { | ||
var id = new Date().getTime(); | ||
var markerText = document.getElementById('markerText').value || undefined; | ||
timeline.addCustomTime(eventProps.time, id); | ||
timeline.setCustomTimeMarker(markerText, id); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>Timeline | Editable markers</title> | ||
|
||
<style type="text/css"> | ||
body, html { | ||
font-family: sans-serif; | ||
font-size: 11pt; | ||
} | ||
</style> | ||
|
||
<script src="../../../dist/vis-timeline-graph2d.min.js"></script> | ||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" /> | ||
|
||
</head> | ||
<body> | ||
|
||
<p>Custom time markers have an option to make the title editable.</p> | ||
|
||
<div id="visualization"></div> | ||
|
||
<script type="text/javascript"> | ||
var container = document.getElementById('visualization'); | ||
var items = new vis.DataSet(); | ||
var customDate = new Date(); | ||
var options = { | ||
start: new Date(Date.now() - 1000 * 60 * 60 * 24), | ||
end: new Date(Date.now() + 1000 * 60 * 60 * 24 * 6) | ||
}; | ||
var timeline = new vis.Timeline(container, items, options); | ||
|
||
var id1 = new Date().getTime(); | ||
var id2 = new Date().getTime(); | ||
timeline.addCustomTime(new Date(customDate.getFullYear(), customDate.getMonth(), customDate.getDate() + 2), id1); | ||
timeline.setCustomTimeMarker("This is editable", id1, true); | ||
timeline.addCustomTime(new Date(customDate.getFullYear(), customDate.getMonth(), customDate.getDate() + 3), id2); | ||
timeline.setCustomTimeMarker("This is not editable", id2, false); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters