Browse Source

Added a file CONTRIBUTING.md

v3_develop
jos 9 years ago
parent
commit
3e9b7ff06c
7 changed files with 25616 additions and 25483 deletions
  1. +16
    -0
      CONTRIBUTING.md
  2. +25495
    -25476
      dist/vis.js
  3. +78
    -0
      examples/timeline/35_item_ordering.html
  4. +1
    -0
      examples/timeline/index.html
  5. +0
    -5
      lib/timeline/Core.js
  6. +25
    -1
      lib/timeline/component/Group.js
  7. +1
    -1
      lib/timeline/component/ItemSet.js

+ 16
- 0
CONTRIBUTING.md View File

@ -0,0 +1,16 @@
## Contributing
Contributions to the vis.js library are very welcome! We can't do this alone.
You can contribute in different ways: spread the word, report bugs, come up with
ideas and suggestions, and contribute to the code.
There are a few preferences regarding code contributions:
- vis.js follows the node.js code style as described
[here](http://nodeguide.com/style.html).
- When implementing new features, please update the documentation accordingly.
- Send pull requests to the `develop` branch, not the `master` branch.
- Only commit changes done in the source files under `lib`, not to the builds
which are located in the folder `dist`.
Thanks!

+ 25495
- 25476
dist/vis.js
File diff suppressed because it is too large
View File


+ 78
- 0
examples/timeline/35_item_ordering.html View File

@ -0,0 +1,78 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Timeline | Item ordering</title>
<style type="text/css">
body, html {
font-family: sans-serif;
}
p {
max-width: 800px;
}
</style>
<script src="../../dist/vis.js"></script>
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Item ordering</h1>
<p>
By default, the items displayed on the Timeline are unordered. They are
stacked in the order that they where loaded. This means that way items are
stacked can change while moving and zooming the Timeline.
</p>
<p>
To display and stack the items in a controlled order, you can provide a
custom sorting function via the configuration option <code>order</code>.
This is only suitable for relatively small amounts of items, as it forces
the Timeline to order and re-stack all items with every redraw.
</p>
<p>
<label for="ordering"><input type="checkbox" id="ordering" checked/> Apply custom ordering. Order items by their id.</label>
</p>
<div id="visualization"></div>
<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');
// Create a DataSet (allows two way data-binding)
var items = new vis.DataSet();
var date = vis.moment('2015-03-02');
for (var i = 0; i < 20; i++) {
date.add(Math.round(Math.random() * 2), 'hour');
items.add({
id: i,
content: 'Item ' + i,
start: date.clone(),
end: date.clone().add(2 + Math.round(Math.random() * 2), 'hour')
});
}
function customOrder (a, b) {
// order by id
return a.id - b.id;
}
// Configuration for the Timeline
var options = {
order: customOrder,
editable: true,
margin: {item: 0}
};
// Create a Timeline
var timeline = new vis.Timeline(container, items, options);
var ordering = document.getElementById('ordering');
ordering.onchange = function () {
timeline.setOptions({
order: ordering.checked ? customOrder: null
});
};
</script>
</body>
</html>

+ 1
- 0
examples/timeline/index.html View File

@ -45,6 +45,7 @@
<p><a href="32_grid_styling.html">32_grid_styling.html</a></p>
<p><a href="33_custom_snapping.html">33_custom_snapping.html</a></p>
<p><a href="34_add_custom_timebar.html">34_add_custom_timebar.html</a></p>
<p><a href="35_item_ordering.html">35_item_ordering.html</a></p>
<p><a href="requirejs/requirejs_example.html">requirejs_example.html</a></p>
</div>

+ 0
- 5
lib/timeline/Core.js View File

@ -242,11 +242,6 @@ Core.prototype.setOptions = function (options) {
component.setOptions(options);
});
// TODO: remove deprecation error one day (deprecated since version 0.8.0)
if (options && options.order) {
throw new Error('Option order is deprecated. There is no replacement for this feature.');
}
// redraw everything
this._redraw();
};

+ 25
- 1
lib/timeline/component/Group.js View File

@ -165,8 +165,15 @@ Group.prototype.redraw = function(range, margin, restack) {
}
// reposition visible items vertically
var customOrderedItems = null;
if (this.itemSet.options.stack) { // TODO: ugly way to access options...
stack.stack(this.visibleItems, margin, restack);
if (typeof this.itemSet.options.order === 'function' || false) {
customOrderedItems = this._getCustomOrderedItems();
stack.stack(customOrderedItems, margin, true);
}
else {
stack.stack(this.visibleItems, margin, restack);
}
}
else { // no stacking
stack.nostack(this.visibleItems, margin, this.subgroups);
@ -483,6 +490,23 @@ Group.prototype._updateVisibleItems = function(orderedItems, oldVisibleItems, ra
return visibleItems;
};
Group.prototype._getCustomOrderedItems = function () {
var customOrderedItems = this.orderedItems.byStart.filter(function (item) {
return item.height !== 0 || item.width !== 0;
});
var me = this;
customOrderedItems.sort(function (a, b) {
return me.itemSet.options.order(a.data, b.data);
});
customOrderedItems.forEach(function (item) {
item.repositionX();
});
return customOrderedItems;
};
Group.prototype._traceVisible = function (initialPos, items, visibleItems, visibleItemsLookup, breakCondition) {
var item;
var i;

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

@ -274,7 +274,7 @@ ItemSet.prototype._create = function(){
ItemSet.prototype.setOptions = function(options) {
if (options) {
// copy all options that we know
var fields = ['type', 'align', 'orientation', 'padding', 'stack', 'selectable', 'groupOrder', 'dataAttributes', 'template','hide', 'snap'];
var fields = ['type', 'align', 'orientation', 'order', 'padding', 'stack', 'selectable', 'groupOrder', 'dataAttributes', 'template','hide', 'snap'];
util.selectiveExtend(fields, this.options, options);
if ('margin' in options) {

Loading…
Cancel
Save