@ -34,10 +34,12 @@ function TimeAxis (body, options) {
} ;
} ;
this . defaultOptions = {
this . defaultOptions = {
orientation : 'bottom' , // axis orientation: 'top' or 'bottom'
orientation : {
axis : 'bottom'
} , // axis orientation: 'top' or 'bottom'
showMinorLabels : true ,
showMinorLabels : true ,
showMajorLabels : true ,
showMajorLabels : true ,
format : null ,
format : TimeStep . FORMAT ,
timeAxis : null
timeAxis : null
} ;
} ;
this . options = util . extend ( { } , this . defaultOptions ) ;
this . options = util . extend ( { } , this . defaultOptions ) ;
@ -56,14 +58,14 @@ TimeAxis.prototype = new Component();
* Set options for the TimeAxis .
* Set options for the TimeAxis .
* Parameters will be merged in current options .
* Parameters will be merged in current options .
* @ param { Object } options Available options :
* @ param { Object } options Available options :
* { string } [ orientation ]
* { string } [ orientation . axis ]
* { boolean } [ showMinorLabels ]
* { boolean } [ showMinorLabels ]
* { boolean } [ showMajorLabels ]
* { boolean } [ showMajorLabels ]
* /
* /
TimeAxis . prototype . setOptions = function ( options ) {
TimeAxis . prototype . setOptions = function ( options ) {
if ( options ) {
if ( options ) {
// copy all options that we know
// copy all options that we know
util . selectiveExtend ( [
util . selectiveDeep Extend ( [
'showMinorLabels' ,
'showMinorLabels' ,
'showMajorLabels' ,
'showMajorLabels' ,
'hiddenDates' ,
'hiddenDates' ,
@ -73,10 +75,10 @@ TimeAxis.prototype.setOptions = function(options) {
if ( 'orientation' in options ) {
if ( 'orientation' in options ) {
if ( typeof options . orientation === 'string' ) {
if ( typeof options . orientation === 'string' ) {
this . options . orientation = options . orientation ;
this . options . orientation . axis = options . orientation ;
}
}
else if ( typeof options . orientation === 'object' && 'axis' in options . orientation ) {
else if ( typeof options . orientation === 'object' && 'axis' in options . orientation ) {
this . options . orientation = options . orientation . axis ;
this . options . orientation . axis = options . orientation . axis ;
}
}
}
}
@ -131,7 +133,7 @@ TimeAxis.prototype.redraw = function () {
var background = this . dom . background ;
var background = this . dom . background ;
// determine the correct parent DOM element (depending on option orientation)
// determine the correct parent DOM element (depending on option orientation)
var parent = ( options . orientation == 'top' ) ? this . body . dom . top : this . body . dom . bottom ;
var parent = ( options . orientation . axis == 'top' ) ? this . body . dom . top : this . body . dom . bottom ;
var parentChanged = ( foreground . parentNode !== parent ) ;
var parentChanged = ( foreground . parentNode !== parent ) ;
// calculate character width and height
// calculate character width and height
@ -148,7 +150,7 @@ TimeAxis.prototype.redraw = function () {
props . width = foreground . offsetWidth ;
props . width = foreground . offsetWidth ;
props . minorLineHeight = this . body . domProps . root . height - props . majorLabelHeight -
props . minorLineHeight = this . body . domProps . root . height - props . majorLabelHeight -
( options . orientation == 'top' ? this . body . domProps . bottom . height : this . body . domProps . top . height ) ;
( options . orientation . axis == 'top' ? this . body . domProps . bottom . height : this . body . domProps . top . height ) ;
props . minorLineWidth = 1 ; // TODO: really calculate width
props . minorLineWidth = 1 ; // TODO: really calculate width
props . majorLineHeight = props . minorLineHeight + props . majorLabelHeight ;
props . majorLineHeight = props . minorLineHeight + props . majorLabelHeight ;
props . majorLineWidth = 1 ; // TODO: really calculate width
props . majorLineWidth = 1 ; // TODO: really calculate width
@ -185,7 +187,7 @@ TimeAxis.prototype.redraw = function () {
* @ private
* @ private
* /
* /
TimeAxis . prototype . _repaintLabels = function ( ) {
TimeAxis . prototype . _repaintLabels = function ( ) {
var orientation = this . options . orientation ;
var orientation = this . options . orientation . axis ;
// calculate range and step (step such that we have space for 7 characters per label)
// calculate range and step (step such that we have space for 7 characters per label)
var start = util . convert ( this . body . range . start , 'Number' ) ;
var start = util . convert ( this . body . range . start , 'Number' ) ;