@ -4154,6 +4154,7 @@ RootPanel.prototype.repaint = function repaint() {
// update frame size
// update frame size
this . frame . style . maxHeight = util . option . asSize ( this . options . maxHeight , '' ) ;
this . frame . style . maxHeight = util . option . asSize ( this . options . maxHeight , '' ) ;
this . frame . style . minHeight = util . option . asSize ( this . options . minHeight , '' ) ;
this . _updateSize ( ) ;
this . _updateSize ( ) ;
// if the root panel or any of its childs is resized, repaint again,
// if the root panel or any of its childs is resized, repaint again,
@ -5034,8 +5035,12 @@ TimeAxis.prototype._repaintLine = function() {
* @ private
* @ private
* /
* /
TimeAxis . prototype . _calculateCharSize = function ( ) {
TimeAxis . prototype . _calculateCharSize = function ( ) {
// Note: We only calculate char size once, but in case it is calculated as zero,
// we will recalculate. This is the case if any of the timelines parents
// has display:none for example.
// determine the char width and height on the minor axis
// determine the char width and height on the minor axis
if ( ! ( 'minorCharHeight' in this . props ) ) {
if ( ! ( 'minorCharHeight' in this . props ) || this . props . minorCharHeight == 0 ) {
var textMinor = document . createTextNode ( '0' ) ;
var textMinor = document . createTextNode ( '0' ) ;
var measureCharMinor = document . createElement ( 'DIV' ) ;
var measureCharMinor = document . createElement ( 'DIV' ) ;
measureCharMinor . className = 'text minor measure' ;
measureCharMinor . className = 'text minor measure' ;
@ -5048,7 +5053,8 @@ TimeAxis.prototype._calculateCharSize = function () {
this . frame . removeChild ( measureCharMinor ) ;
this . frame . removeChild ( measureCharMinor ) ;
}
}
if ( ! ( 'majorCharHeight' in this . props ) ) {
// determine the char width and height on the major axis
if ( ! ( 'majorCharHeight' in this . props ) || this . props . majorCharHeight == 0 ) {
var textMajor = document . createTextNode ( '0' ) ;
var textMajor = document . createTextNode ( '0' ) ;
var measureCharMajor = document . createElement ( 'DIV' ) ;
var measureCharMajor = document . createElement ( 'DIV' ) ;
measureCharMajor . className = 'text major measure' ;
measureCharMajor . className = 'text major measure' ;
@ -7744,6 +7750,14 @@ Group.prototype._create = function() {
this . dom . background = document . createElement ( 'div' ) ;
this . dom . background = document . createElement ( 'div' ) ;
this . dom . axis = document . createElement ( 'div' ) ;
this . dom . axis = document . createElement ( 'div' ) ;
// create a hidden marker to detect when the Timelines container is attached
// to the DOM, or the style of a parent of the Timeline is changed from
// display:none is changed to visible.
this . dom . marker = document . createElement ( 'div' ) ;
this . dom . marker . style . visibility = 'hidden' ;
this . dom . marker . innerHTML = '?' ;
this . dom . background . appendChild ( this . dom . marker ) ;
} ;
} ;
/ * *
/ * *
@ -7815,6 +7829,20 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
this . visibleItems = this . _updateVisibleItems ( this . orderedItems , this . visibleItems , range ) ;
this . visibleItems = this . _updateVisibleItems ( this . orderedItems , this . visibleItems , range ) ;
// force recalculation of the height of the items when the marker height changed
// (due to the Timeline being attached to the DOM or changed from display:none to visible)
var markerHeight = this . dom . marker . clientHeight ;
if ( markerHeight != this . lastMarkerHeight ) {
this . lastMarkerHeight = markerHeight ;
util . forEach ( this . items , function ( item ) {
item . dirty = true ;
if ( item . displayed ) item . repaint ( ) ;
} ) ;
restack = true ;
}
// reposition visible items vertically
// reposition visible items vertically
if ( this . itemSet . options . stack ) { // TODO: ugly way to access options...
if ( this . itemSet . options . stack ) { // TODO: ugly way to access options...
stack . stack ( this . visibleItems , margin , restack ) ;
stack . stack ( this . visibleItems , margin , restack ) ;
@ -7822,7 +7850,6 @@ Group.prototype.repaint = function repaint(range, margin, restack) {
else { // no stacking
else { // no stacking
stack . nostack ( this . visibleItems , margin ) ;
stack . nostack ( this . visibleItems , margin ) ;
}
}
this . stackDirty = false ;
for ( var i = 0 , ii = this . visibleItems . length ; i < ii ; i ++ ) {
for ( var i = 0 , ii = this . visibleItems . length ; i < ii ; i ++ ) {
var item = this . visibleItems [ i ] ;
var item = this . visibleItems [ i ] ;
item . repositionY ( ) ;
item . repositionY ( ) ;
@ -8690,7 +8717,7 @@ Timeline.prototype.getSelection = function getSelection() {
* Where start and end can be a Date , number , or string , and range is an
* Where start and end can be a Date , number , or string , and range is an
* object with properties start and end .
* object with properties start and end .
*
*
* @ param { Date | Number | String } [ start ] Start date of visible window
* @ param { Date | Number | String | Object } [ start ] Start date of visible window
* @ param { Date | Number | String } [ end ] End date of visible window
* @ param { Date | Number | String } [ end ] End date of visible window
* /
* /
Timeline . prototype . setWindow = function setWindow ( start , end ) {
Timeline . prototype . setWindow = function setWindow ( start , end ) {
@ -8715,6 +8742,14 @@ Timeline.prototype.getWindow = function setWindow() {
} ;
} ;
} ;
} ;
/ * *
* Force a repaint of the Timeline . Can be useful to manually repaint when
* option autoResize = false
* /
Timeline . prototype . repaint = function repaint ( ) {
this . rootPanel . repaint ( ) ;
} ;
/ * *
/ * *
* Handle selecting / deselecting an item when tapping it
* Handle selecting / deselecting an item when tapping it
* @ param { Event } event
* @ param { Event } event
@ -8781,6 +8816,11 @@ Timeline.prototype._onAddItem = function (event) {
content : 'new item'
content : 'new item'
} ;
} ;
// when default type is a range, add a default end date to the new item
if ( this . options . type === 'range' || this . options . type == 'rangeoverflow' ) {
newItem . end = this . timeAxis . snap ( this . _toTime ( x + this . rootPanel . width / 5 ) ) ;
}
var id = util . randomUUID ( ) ;
var id = util . randomUUID ( ) ;
newItem [ this . itemsData . fieldId ] = id ;
newItem [ this . itemsData . fieldId ] = id ;
@ -13694,10 +13734,10 @@ var manipulationMixin = {
this . cachedFunctions [ "_handleOnDrag" ] = this . _handleOnDrag ;
this . cachedFunctions [ "_handleOnDrag" ] = this . _handleOnDrag ;
this . _handleOnDrag = function ( event ) {
this . _handleOnDrag = function ( event ) {
var pointer = this . _getPointer ( event . gesture . center ) ;
var pointer = this . _getPointer ( event . gesture . center ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetNode' ] . x = this . _canvasToX ( pointer . x ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetNode' ] . y = this . _canvasToY ( pointer . y ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetViaNode' ] . x = 0.5 * ( this . _canvasToX ( pointer . x ) + this . edges [ 'connectionEdge' ] . from . x ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetViaNode' ] . y = this . _canvasToY ( pointer . y ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetNode' ] . x = this . _X convertDOMtoC anvas ( pointer . x ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetNode' ] . y = this . _Y convertDOMtoC anvas ( pointer . y ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetViaNode' ] . x = 0.5 * ( this . _X convertDOMtoC anvas ( pointer . x ) + this . edges [ 'connectionEdge' ] . from . x ) ;
this . sectors [ 'support' ] [ 'nodes' ] [ 'targetViaNode' ] . y = this . _Y convertDOMtoC anvas ( pointer . y ) ;
} ;
} ;
this . moving = true ;
this . moving = true ;
@ -15620,8 +15660,8 @@ var SelectionMixin = {
* @ private
* @ private
* /
* /
_pointerToPositionObject : function ( pointer ) {
_pointerToPositionObject : function ( pointer ) {
var x = this . _canvasToX ( pointer . x ) ;
var y = this . _canvasToY ( pointer . y ) ;
var x = this . _X convertDOMtoC anvas ( pointer . x ) ;
var y = this . _Y convertDOMtoC anvas ( pointer . y ) ;
return { left : x ,
return { left : x ,
top : y ,
top : y ,
@ -16013,8 +16053,8 @@ var SelectionMixin = {
var node = this . _getNodeAt ( pointer ) ;
var node = this . _getNodeAt ( pointer ) ;
if ( node != null && node !== undefined ) {
if ( node != null && node !== undefined ) {
// we reset the areaCenter here so the opening of the node will occur
// we reset the areaCenter here so the opening of the node will occur
this . areaCenter = { "x" : this . _canvasToX ( pointer . x ) ,
"y" : this . _canvasToY ( pointer . y ) } ;
this . areaCenter = { "x" : this . _X convertDOMtoC anvas ( pointer . x ) ,
"y" : this . _Y convertDOMtoC anvas ( pointer . y ) } ;
this . openCluster ( node ) ;
this . openCluster ( node ) ;
}
}
this . emit ( "doubleClick" , this . getSelection ( ) ) ;
this . emit ( "doubleClick" , this . getSelection ( ) ) ;
@ -17513,11 +17553,11 @@ Graph.prototype._handleOnDrag = function(event) {
var node = s . node ;
var node = s . node ;
if ( ! s . xFixed ) {
if ( ! s . xFixed ) {
node . x = me . _canvasToX ( me . _xToCanvas ( s . x ) + deltaX ) ;
node . x = me . _X convertDOMtoC anvas ( me . _XconvertCanvasToDOM ( s . x ) + deltaX ) ;
}
}
if ( ! s . yFixed ) {
if ( ! s . yFixed ) {
node . y = me . _canvasToY ( me . _yToCanvas ( s . y ) + deltaY ) ;
node . y = me . _Y convertDOMtoC anvas ( me . _YconvertCanvasToDOM ( s . y ) + deltaY ) ;
}
}
} ) ;
} ) ;
@ -17643,8 +17683,8 @@ Graph.prototype._zoom = function(scale, pointer) {
var tx = ( 1 - scaleFrac ) * pointer . x + translation . x * scaleFrac ;
var tx = ( 1 - scaleFrac ) * pointer . x + translation . x * scaleFrac ;
var ty = ( 1 - scaleFrac ) * pointer . y + translation . y * scaleFrac ;
var ty = ( 1 - scaleFrac ) * pointer . y + translation . y * scaleFrac ;
this . areaCenter = { "x" : this . _canvasToX ( pointer . x ) ,
"y" : this . _canvasToY ( pointer . y ) } ;
this . areaCenter = { "x" : this . _X convertDOMtoC anvas ( pointer . x ) ,
"y" : this . _Y convertDOMtoC anvas ( pointer . y ) } ;
this . _setScale ( scale ) ;
this . _setScale ( scale ) ;
this . _setTranslation ( tx , ty ) ;
this . _setTranslation ( tx , ty ) ;
@ -17745,10 +17785,10 @@ Graph.prototype._onMouseMoveTitle = function (event) {
* /
* /
Graph . prototype . _checkShowPopup = function ( pointer ) {
Graph . prototype . _checkShowPopup = function ( pointer ) {
var obj = {
var obj = {
left : this . _canvasToX ( pointer . x ) ,
top : this . _canvasToY ( pointer . y ) ,
right : this . _canvasToX ( pointer . x ) ,
bottom : this . _canvasToY ( pointer . y )
left : this . _X convertDOMtoC anvas ( pointer . x ) ,
top : this . _Y convertDOMtoC anvas ( pointer . y ) ,
right : this . _X convertDOMtoC anvas ( pointer . x ) ,
bottom : this . _Y convertDOMtoC anvas ( pointer . y )
} ;
} ;
var id ;
var id ;
@ -18212,12 +18252,12 @@ Graph.prototype._redraw = function() {
ctx . scale ( this . scale , this . scale ) ;
ctx . scale ( this . scale , this . scale ) ;
this . canvasTopLeft = {
this . canvasTopLeft = {
"x" : this . _canvasToX ( 0 ) ,
"y" : this . _canvasToY ( 0 )
"x" : this . _X convertDOMtoC anvas ( 0 ) ,
"y" : this . _Y convertDOMtoC anvas ( 0 )
} ;
} ;
this . canvasBottomRight = {
this . canvasBottomRight = {
"x" : this . _canvasToX ( this . frame . canvas . clientWidth ) ,
"y" : this . _canvasToY ( this . frame . canvas . clientHeight )
"x" : this . _X convertDOMtoC anvas ( this . frame . canvas . clientWidth ) ,
"y" : this . _Y convertDOMtoC anvas ( this . frame . canvas . clientHeight )
} ;
} ;
this . _doInAllSectors ( "_drawAllSectorNodes" , ctx ) ;
this . _doInAllSectors ( "_drawAllSectorNodes" , ctx ) ;
@ -18286,42 +18326,46 @@ Graph.prototype._getScale = function() {
} ;
} ;
/ * *
/ * *
* Convert a horizontal point on the HTML canvas to the x - value of the model
* Convert the X coordinate in DOM - space ( coordinate point in browser relative to the container div ) to
* the X coordinate in canvas - space ( the simulation sandbox , which the camera looks upon )
* @ param { number } x
* @ param { number } x
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
Graph . prototype . _canvasToX = function ( x ) {
Graph . prototype . _X convertDOMtoC anvas = function ( x ) {
return ( x - this . translation . x ) / this . scale ;
return ( x - this . translation . x ) / this . scale ;
} ;
} ;
/ * *
/ * *
* Convert an x - value in the model to a horizontal point on the HTML canvas
* Convert the X coordinate in canvas - space ( the simulation sandbox , which the camera looks upon ) to
* the X coordinate in DOM - space ( coordinate point in browser relative to the container div )
* @ param { number } x
* @ param { number } x
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
Graph . prototype . _xToCanvas = function ( x ) {
Graph . prototype . _XconvertCanvasToDOM = function ( x ) {
return x * this . scale + this . translation . x ;
return x * this . scale + this . translation . x ;
} ;
} ;
/ * *
/ * *
* Convert a vertical point on the HTML canvas to the y - value of the model
* Convert the Y coordinate in DOM - space ( coordinate point in browser relative to the container div ) to
* the Y coordinate in canvas - space ( the simulation sandbox , which the camera looks upon )
* @ param { number } y
* @ param { number } y
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
Graph . prototype . _canvasToY = function ( y ) {
Graph . prototype . _Y convertDOMtoC anvas = function ( y ) {
return ( y - this . translation . y ) / this . scale ;
return ( y - this . translation . y ) / this . scale ;
} ;
} ;
/ * *
/ * *
* Convert an y - value in the model to a vertical point on the HTML canvas
* Convert the Y coordinate in canvas - space ( the simulation sandbox , which the camera looks upon ) to
* the Y coordinate in DOM - space ( coordinate point in browser relative to the container div )
* @ param { number } y
* @ param { number } y
* @ returns { number }
* @ returns { number }
* @ private
* @ private
* /
* /
Graph . prototype . _yToCanvas = function ( y ) {
Graph . prototype . _YconvertCanvasToDOM = function ( y ) {
return y * this . scale + this . translation . y ;
return y * this . scale + this . translation . y ;
} ;
} ;
@ -18333,7 +18377,7 @@ Graph.prototype._yToCanvas = function(y) {
* @ constructor
* @ constructor
* /
* /
Graph . prototype . canvasToDOM = function ( pos ) {
Graph . prototype . canvasToDOM = function ( pos ) {
return { x : this . _xToCanvas ( pos . x ) , y : this . _yToCanvas ( pos . y ) } ;
return { x : this . _XconvertCanvasToDOM ( pos . x ) , y : this . _YconvertCanvasToDOM ( pos . y ) } ;
}
}
/ * *
/ * *
@ -18343,7 +18387,7 @@ Graph.prototype.canvasToDOM = function(pos) {
* @ constructor
* @ constructor
* /
* /
Graph . prototype . DOMtoCanvas = function ( pos ) {
Graph . prototype . DOMtoCanvas = function ( pos ) {
return { x : this . _canvasToX ( pos . x ) , y : this . _canvasToY ( pos . y ) } ;
return { x : this . _X convertDOMtoC anvas ( pos . x ) , y : this . _Y convertDOMtoC anvas ( pos . y ) } ;
}
}
/ * *
/ * *
@ -18753,6 +18797,7 @@ Graph.prototype.storePosition = function() {
* /
* /
var vis = {
var vis = {
util : util ,
util : util ,
moment : moment ,
DataSet : DataSet ,
DataSet : DataSet ,
DataView : DataView ,
DataView : DataView ,