1 /**
  2  * Mixin for a track that has a Y-axis scale bar on its left side.
  3  * Puts the scale div in <code>this.yscale</code>, stores the 'left' CSS pixel
  4  * offset in <code>this.yscale_left</code>.
  5  * @class
  6  */
  7 
  8 var Track; if( !Track ) Track = {};
  9 
 10 Track.YScaleMixin = {
 11 
 12     /**
 13      * @param {Number} [min] Optional minimum value for the scale.
 14      * Defaults to value of <code>this.min</code>.
 15      * @param {Number} [max] Optional maximum value for the scale.
 16      * Defaults to value of <code>this.max</code>.
 17      */
 18     makeYScale: function( args ) {
 19         var min = args && typeof args.min == 'number' ? args.min : this.min;
 20         var max = args && typeof args.max == 'number' ? args.max : this.max;
 21 
 22         // make and style the main container div for the axis
 23         var rulerdiv = document.createElement('div');
 24         this.yscale = rulerdiv;
 25         rulerdiv.className = 'ruler vertical_ruler';
 26         dojo.style( rulerdiv, {
 27                         height: this.height+'px',
 28                         position: 'absolute',
 29                         width: "100px",
 30                         zIndex: 17
 31                     });
 32 
 33         if( this.window_info && 'x' in this.window_info )
 34             rulerdiv.style.left = (this.window_info.x + (this.window_info.width||0)/2)+ "px";
 35 
 36         dojo.style(
 37             rulerdiv,
 38             ( this.config.align == 'top' ? { top: '0px' } :
 39               { bottom: this.trackPadding+"px"})
 40         );
 41         this.div.appendChild( rulerdiv );
 42 
 43         // now make a Ruler and draw the axis in the div we just made
 44         var ruler = new Ruler({
 45             min: min,
 46             max: max,
 47             direction: 'up'
 48         });
 49         ruler.render_to( rulerdiv );
 50     },
 51 
 52     updateYScaleFromViewDimensions: function( coords ) {
 53         if( typeof coords.x == 'number' || typeof coords.width == 'number' ) {
 54             if( this.yscale )
 55                 this.yscale.style.left = (this.window_info.x + (this.window_info.width||0)/2) + "px";
 56         }
 57     }
 58 };
 59