TopAxisLayout.js revision 14bfa36e35102dbf271dcff98f773a01c75bd503
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Contains algorithms for rendering a top axis.
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp * @module charts
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @class TopAxisLayout
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @constructor
a5057260e5538ddf2faca20fa81271eeff2bf892TrippTopAxisLayout = function(){};
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Default margins for text fields.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method _getDefaultMargins
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Sets the length of the tick on either side of the axis line.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method setTickOffsets
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp case "inside" :
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp case "outside" :
7174b256e7956a8efaff0352e7cac98b942f804fTripp case "cross" :
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Calculates the coordinates for the first point on an axis.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method getLineStart
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Draws a tick
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method drawTick
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp * @param {Path} path reference to the path `Path` element in which to draw the tick.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Object} pt hash containing x and y coordinates
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Object} tickStyles hash of properties used to draw the tick
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Calculates the point for a label.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method getLabelPoint
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Object} pt hash containing x and y coordinates
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @return Object
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Updates the value for the `maxLabelSize` for use in calculating total size.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method updateMaxLabelSize
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {HTMLElement} label to measure
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp max = (sinRadians * labelWidth) + (cosRadians * labelHeight);
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp host._maxLabelSize = Math.max(host._maxLabelSize, max);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Rotate and position title.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method positionTitle
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} label to rotate position
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp max = (sinRadians * labelWidth) + (cosRadians * labelHeight);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp leftOffset -= (cosRadians * labelWidth)/2 - (sinRadians * labelHeight)/2;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp leftOffset -= (cosRadians * labelWidth)/2 + (sinRadians * labelHeight)/2;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp max = (sinRadians * labelWidth) + (cosRadians * labelHeight);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp leftOffset -= ((cosRadians * labelWidth) + (sinRadians * labelHeight))/2;
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Rotate and position labels.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method positionLabel
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {HTMLElement} label to rotate position
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Object} pt hash containing the x and y coordinates in which the label will be positioned
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp totalTitleSize = this.get("title") ? this._titleSize + titleStyles.margin.top + titleStyles.margin.bottom : 0,
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= labelHeight - (labelHeight * absRot/180);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Calculates the size and positions the content elements.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method setSizeAndPosition
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp sz += this._titleSize + titleMargin.top + titleMargin.bottom;
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Adjusts position for inner ticks.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method offsetNodeForTick
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Node} cb contentBox of the axis
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Assigns a height based on the size of the contents.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method setCalculatedSize
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp totalLabelSize = labelMargin.bottom + host._maxLabelSize,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp totalTitleSize = host.get("title") ? titleMargin.top + titleMargin.bottom + host._titleSize : 0,