Browse Source

Fixed items not automatically being repainted on changed data

css_transitions
josdejong 11 years ago
parent
commit
e6546fe4dc
7 changed files with 32 additions and 25 deletions
  1. +6
    -6
      src/component/item/itembox.js
  2. +3
    -0
      src/component/itemset.js
  3. +1
    -1
      src/component/rootpanel.js
  4. +2
    -2
      src/visualization/timeline.js
  5. +5
    -4
      test/timeline.html
  6. +12
    -9
      vis.js
  7. +3
    -3
      vis.min.js

+ 6
- 6
src/component/item/itembox.js View File

@ -224,22 +224,22 @@ ItemBox.prototype.reflow = function reflow() {
// default or 'center' // default or 'center'
left = start - this.width / 2; left = start - this.width / 2;
} }
update(this, 'left', left);
changed += update(this, 'left', left);
update(props.line, 'left', start - props.line.width / 2);
update(props.dot, 'left', start - props.dot.width / 2);
update(props.dot, 'top', -props.dot.height / 2);
changed += update(props.line, 'left', start - props.line.width / 2);
changed += update(props.dot, 'left', start - props.dot.width / 2);
changed += update(props.dot, 'top', -props.dot.height / 2);
if (orientation == 'top') { if (orientation == 'top') {
top = margin; top = margin;
update(this, 'top', top);
changed += update(this, 'top', top);
} }
else { else {
// default or 'bottom' // default or 'bottom'
var parentHeight = this.parent.height; var parentHeight = this.parent.height;
top = parentHeight - this.height - margin; top = parentHeight - this.height - margin;
update(this, 'top', top);
changed += update(this, 'top', top);
} }
} }
else { else {

+ 3
- 0
src/component/itemset.js View File

@ -239,6 +239,9 @@ ItemSet.prototype.repaint = function repaint() {
} }
} }
// force a repaint (not only a reposition)
item.repaint();
items[id] = item; items[id] = item;
} }

+ 1
- 1
src/component/rootpanel.js View File

@ -10,7 +10,7 @@ function RootPanel(container, options) {
this.id = util.randomUUID(); this.id = util.randomUUID();
this.container = container; this.container = container;
this.options = options || {}
this.options = options || {};
this.defaultOptions = { this.defaultOptions = {
autoResize: true autoResize: true
}; };

+ 2
- 2
src/visualization/timeline.js View File

@ -7,7 +7,7 @@
*/ */
function Timeline (container, items, options) { function Timeline (container, items, options) {
var me = this; var me = this;
this.options = {
this.options = util.extend({
orientation: 'bottom', orientation: 'bottom',
min: null, min: null,
max: null, max: null,
@ -18,7 +18,7 @@ function Timeline (container, items, options) {
showMinorLabels: true, showMinorLabels: true,
showMajorLabels: true, showMajorLabels: true,
autoResize: false autoResize: false
};
}, options);
// controller // controller
this.controller = new Controller(); this.controller = new Controller();

+ 5
- 4
test/timeline.html View File

@ -40,14 +40,14 @@
<script> <script>
// create a dataset with items // create a dataset with items
var now = moment().minutes(0).seconds(0).milliseconds(0); var now = moment().minutes(0).seconds(0).milliseconds(0);
var data = new vis.DataSet({
var items = new vis.DataSet({
fieldTypes: { fieldTypes: {
start: 'Date', start: 'Date',
end: 'Date' end: 'Date'
}, },
fieldId: '_id' fieldId: '_id'
}); });
data.add([
items.add([
{_id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()}, {_id: 1, content: 'item 1<br>start', start: now.clone().add('days', 4).toDate()},
{_id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() }, {_id: 2, content: 'item 2', start: now.clone().add('days', -2).toDate() },
{_id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()}, {_id: 3, content: 'item 3', start: now.clone().add('days', 2).toDate()},
@ -60,16 +60,17 @@
var container = document.getElementById('visualization'); var container = document.getElementById('visualization');
var options = { var options = {
//orientation: 'top',
//start: now.clone().add('days', -7).valueOf(), //start: now.clone().add('days', -7).valueOf(),
//end: now.clone().add('days', 7).valueOf(), //end: now.clone().add('days', 7).valueOf(),
//maxHeight: 200,
min: moment('2013-01-01').valueOf(), min: moment('2013-01-01').valueOf(),
max: moment('2013-12-31').valueOf(), max: moment('2013-12-31').valueOf(),
//maxHeight: 200,
zoomMin: 1000 * 60 * 60 * 24, // 1 day zoomMin: 1000 * 60 * 60 * 24, // 1 day
zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months zoomMax: 1000 * 60 * 60 * 24 * 30 * 6 // 6 months
}; };
var timeline = new vis.Timeline(container, data, options);
var timeline = new vis.Timeline(container, items, options);
</script> </script>
</body> </body>

+ 12
- 9
vis.js View File

@ -3834,7 +3834,7 @@ function RootPanel(container, options) {
this.id = util.randomUUID(); this.id = util.randomUUID();
this.container = container; this.container = container;
this.options = options || {}
this.options = options || {};
this.defaultOptions = { this.defaultOptions = {
autoResize: true autoResize: true
}; };
@ -4793,6 +4793,9 @@ ItemSet.prototype.repaint = function repaint() {
} }
} }
// force a repaint (not only a reposition)
item.repaint();
items[id] = item; items[id] = item;
} }
@ -5378,22 +5381,22 @@ ItemBox.prototype.reflow = function reflow() {
// default or 'center' // default or 'center'
left = start - this.width / 2; left = start - this.width / 2;
} }
update(this, 'left', left);
changed += update(this, 'left', left);
update(props.line, 'left', start - props.line.width / 2);
update(props.dot, 'left', start - props.dot.width / 2);
update(props.dot, 'top', -props.dot.height / 2);
changed += update(props.line, 'left', start - props.line.width / 2);
changed += update(props.dot, 'left', start - props.dot.width / 2);
changed += update(props.dot, 'top', -props.dot.height / 2);
if (orientation == 'top') { if (orientation == 'top') {
top = margin; top = margin;
update(this, 'top', top);
changed += update(this, 'top', top);
} }
else { else {
// default or 'bottom' // default or 'bottom'
var parentHeight = this.parent.height; var parentHeight = this.parent.height;
top = parentHeight - this.height - margin; top = parentHeight - this.height - margin;
update(this, 'top', top);
changed += update(this, 'top', top);
} }
} }
else { else {
@ -6468,7 +6471,7 @@ GroupSet.prototype._toQueue = function _toQueue(ids, action) {
*/ */
function Timeline (container, items, options) { function Timeline (container, items, options) {
var me = this; var me = this;
this.options = {
this.options = util.extend({
orientation: 'bottom', orientation: 'bottom',
min: null, min: null,
max: null, max: null,
@ -6479,7 +6482,7 @@ function Timeline (container, items, options) {
showMinorLabels: true, showMinorLabels: true,
showMajorLabels: true, showMajorLabels: true,
autoResize: false autoResize: false
};
}, options);
// controller // controller
this.controller = new Controller(); this.controller = new Controller();

+ 3
- 3
vis.min.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save