<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Timeline | Individual editable items</title>
|
|
|
|
<style>
|
|
body, html {
|
|
font-family: arial, sans-serif;
|
|
font-size: 11pt;
|
|
}
|
|
|
|
div.vis-editable,
|
|
div.vis-editable.vis-selected {
|
|
/* custom styling for editable items... */
|
|
}
|
|
|
|
div.vis-readonly,
|
|
div.vis-readonly.vis-selected {
|
|
/* custom styling for readonly items... */
|
|
background-color: #ff4500;
|
|
border-color: red;
|
|
color: white;
|
|
}
|
|
</style>
|
|
|
|
<script src="../../../dist/vis.js"></script>
|
|
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<p>Specify individual items to be editable or readonly. Toggle edit options and override behavior from timeline.editable</p>
|
|
|
|
<div id="visualization"></div>
|
|
<p>
|
|
<form>
|
|
Timeline.editable = {</br>
|
|
<input name="add" type="checkbox" checked>add</input></br>
|
|
<input name="remove" type="checkbox" checked>remove</input></br>
|
|
<input name="updateGroup" type="checkbox">updateGroup</input></br>
|
|
<input name="updateTime" type="checkbox" checked>updateTime</input><br>
|
|
<input name="overrideItems" type="checkbox">overrideItems</input><br>
|
|
}
|
|
</form>
|
|
</p>
|
|
<script>
|
|
// create a DataSet with items
|
|
var items = new vis.DataSet([
|
|
{id: 1, content: 'Editable', editable: true, start: '2010-08-23', group: 1},
|
|
{id: 2, content: 'Editable', editable: true, start: '2010-08-23T23:00:00', group: 2},
|
|
{id: 3, content: 'Read-only', editable: false, start: '2010-08-24T16:00:00', group: 1},
|
|
{id: 4, content: 'Read-only', editable: false, start: '2010-08-26', end: '2010-09-02', group: 2},
|
|
{id: 5, content: 'Editable', editable: true, start: '2010-08-28', group: 1},
|
|
{id: 6, content: 'Read-only', editable: false, start: '2010-08-29', group: 2},
|
|
{id: 7, content: 'Editable', editable: true, start: '2010-08-31', end: '2010-09-03', group: 1},
|
|
{id: 8, content: 'Read-only', editable: false, start: '2010-09-04T12:00:00', group: 2},
|
|
{id: 9, content: 'Default', start: '2010-09-04', group: 1},
|
|
{id: 10, content: 'Default', start: '2010-08-24', group: 2}
|
|
]);
|
|
|
|
var groups = [
|
|
{
|
|
id: 1,
|
|
content: 'group 1'
|
|
},
|
|
{
|
|
id: 2,
|
|
content: 'group 2'
|
|
}
|
|
]
|
|
|
|
var container = document.getElementById('visualization');
|
|
var options = {
|
|
editable: {
|
|
add: true,
|
|
remove: true,
|
|
updateGroup: false,
|
|
updateTime: true,
|
|
overrideItems: false
|
|
} // default for all items
|
|
};
|
|
|
|
var timeline = new vis.Timeline(container, items, groups, options);
|
|
|
|
var updateEditOptions = function(e){
|
|
var changedOption = e.target.name;
|
|
var options = { editable: { } };
|
|
options.editable[changedOption] = e.target.checked;
|
|
timeline.setOptions(options);
|
|
};
|
|
|
|
var cbs = document.getElementsByTagName("input");
|
|
[].forEach.call(cbs, function(cb){
|
|
cb.onchange = updateEditOptions;
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|