e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp/**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Contains algorithms for rendering a top axis.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp * @module charts
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @class TopAxisLayout
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @constructor
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
a5057260e5538ddf2faca20fa81271eeff2bf892TrippTopAxisLayout = function(){};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
a5057260e5538ddf2faca20fa81271eeff2bf892TrippTopAxisLayout.prototype = {
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp /**
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Default margins for text fields.
422668e1d4513bb870b8b576fd9d828c8872f074Tripp *
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @private
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method _getDefaultMargins
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @return Object
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp */
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp _getDefaultMargins: function()
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp top: 0,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp left: 0,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp right: 0,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp bottom: 4
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp };
4beb671b9f23325489cc74a7950f2b1f1420b5f3Tripp },
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Sets the length of the tick on either side of the axis line.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method setTickOffsets
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setTickOffsets: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp majorTicks = host.get("styles").majorTicks,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tickLength = majorTicks.length,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp halfTick = tickLength * 0.5,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp display = majorTicks.display;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("leftTickOffset", 0);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("rightTickOffset", 0);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp switch(display)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp case "inside" :
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("bottomTickOffset", tickLength);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("topTickOffset", 0);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp break;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp case "outside" :
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("bottomTickOffset", 0);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("topTickOffset", tickLength);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp break;
7174b256e7956a8efaff0352e7cac98b942f804fTripp case "cross" :
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("topTickOffset", halfTick);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("bottomTickOffset", halfTick);
7174b256e7956a8efaff0352e7cac98b942f804fTripp break;
7174b256e7956a8efaff0352e7cac98b942f804fTripp default:
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("topTickOffset", 0);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp host.set("bottomTickOffset", 0);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp break;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Calculates the coordinates for the first point on an axis.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method getLineStart
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getLineStart: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp style = host.get("styles"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp padding = style.padding,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp majorTicks = style.majorTicks,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tickLength = majorTicks.length,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp display = majorTicks.display,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp pt = {x:0, y:padding.top};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(display === "outside")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp pt.y += tickLength;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else if(display === "cross")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp pt.y += tickLength/2;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return pt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Draws a tick
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
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
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp drawTick: function(path, pt, tickStyles)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp style = host.get("styles"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp padding = style.padding,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tickLength = tickStyles.length,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp start = {x:pt.x, y:padding.top},
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp end = {x:pt.x, y:tickLength + padding.top};
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp host.drawLine(path, start, end);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Calculates the point for a label.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method getLabelPoint
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Object} pt hash containing x and y coordinates
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @return Object
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getLabelPoint: function(pt)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp return {x:pt.x, y:pt.y - this.get("topTickOffset")};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Updates the value for the `maxLabelSize` for use in calculating total size.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method updateMaxLabelSize
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {HTMLElement} label to measure
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp */
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp updateMaxLabelSize: function(labelWidth, labelHeight)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp props = this._labelRotationProps,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp rot = props.rot,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp absRot = props.absRot,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp sinRadians = props.sinRadians,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp cosRadians = props.cosRadians,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp max;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp if(rot === 0)
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp max = labelHeight;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp }
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp else if(absRot === 90)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp max = labelWidth;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp max = (sinRadians * labelWidth) + (cosRadians * labelHeight);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp }
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp host._maxLabelSize = Math.max(host._maxLabelSize, max);
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp },
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp /**
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp * Determines the available label height when the axis width has been explicitly set.
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp *
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp * @method getExplicitlySized
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp * @return Boolean
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp * @protected
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp */
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp getExplicitlySized: function(styles)
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp {
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp if(this._explicitHeight)
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp {
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp var host = this,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp h = host._explicitHeight,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp totalTitleSize = host._totalTitleSize,
68d2a3ded2307a5031fec19a1725a36821ab97a0Tripp topTickOffset = host.get("topTickOffset"),
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp margin = styles.label.margin.right;
68d2a3ded2307a5031fec19a1725a36821ab97a0Tripp host._maxLabelSize = h - (topTickOffset + margin + totalTitleSize);
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp return true;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp }
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp return false;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp },
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp /**
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * Rotate and position title.
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp *
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @method positionTitle
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @param {HTMLElement} label to rotate position
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp * @protected
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp */
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp positionTitle: function(label)
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp bounds = host._titleBounds,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp margin = host.get("styles").title.margin,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props = host._titleRotationProps,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp labelWidth = label.offsetWidth,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp labelHeight = label.offsetHeight,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp h = bounds.bottom - bounds.top,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp x = (host.get("width") * 0.5) - (labelWidth * 0.5),
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp y = h/2 - labelHeight/2;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props.labelWidth = labelWidth;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props.labelHeight = labelHeight;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp if(margin && margin.top)
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp {
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp y += margin.top;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props.x = x;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props.y = y;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp props.transformOrigin = [0.5, 0.5];
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp host._rotate(label, props);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp /**
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Rotate and position labels.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
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
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * against.
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp */
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp positionLabel: function(label, pt, styles, i)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp totalTitleSize = this._totalTitleSize,
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp maxLabelSize = host._maxLabelSize,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp leftOffset = pt.x,
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset = pt.y + totalTitleSize + maxLabelSize,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp props = this._labelRotationProps,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp rot = props.rot,
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp absRot = props.absRot,
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp labelWidth = this._labelWidths[i],
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp labelHeight = this._labelHeights[i];
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp if(rot === 0)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp leftOffset -= labelWidth * 0.5;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= labelHeight;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp }
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp else
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp if(rot === 90)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp leftOffset -= labelWidth;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= (labelHeight * 0.5);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp else if (rot === -90)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= (labelHeight * 0.5);
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else if(rot > 0)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp leftOffset -= labelWidth;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= labelHeight - (labelHeight * rot/180);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp topOffset -= labelHeight - (labelHeight * absRot/180);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
6aa3a8d9176704373c2e24b0530b508f643fe6a0Tripp props.x = Math.round(leftOffset);
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp props.y = Math.round(topOffset);
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp props.labelWidth = labelWidth;
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp props.labelHeight = labelHeight;
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp this._rotate(label, props);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
5c25e6d712b880e314278e6395068dd208553b98Tripp
5c25e6d712b880e314278e6395068dd208553b98Tripp /**
5c25e6d712b880e314278e6395068dd208553b98Tripp * Adjusts the coordinates of an axis label based on the rotation.
5c25e6d712b880e314278e6395068dd208553b98Tripp *
5c25e6d712b880e314278e6395068dd208553b98Tripp * @method _setRotationCoords
5c25e6d712b880e314278e6395068dd208553b98Tripp * @param {Object} props Coordinates, dimension and rotation properties of the label.
5c25e6d712b880e314278e6395068dd208553b98Tripp * @protected
5c25e6d712b880e314278e6395068dd208553b98Tripp */
5c25e6d712b880e314278e6395068dd208553b98Tripp _setRotationCoords: function(props)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp var rot = props.rot,
5c25e6d712b880e314278e6395068dd208553b98Tripp absRot = props.absRot,
5c25e6d712b880e314278e6395068dd208553b98Tripp labelWidth = props.labelWidth,
5c25e6d712b880e314278e6395068dd208553b98Tripp labelHeight = props.labelHeight,
5c25e6d712b880e314278e6395068dd208553b98Tripp leftOffset,
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset;
5c25e6d712b880e314278e6395068dd208553b98Tripp if(rot === 0)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp leftOffset = labelWidth * 0.5;
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset = labelHeight;
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp if(rot === 90)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp leftOffset = labelWidth;
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset = (labelHeight * 0.5);
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else if (rot === -90)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset = (labelHeight * 0.5);
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else if(rot > 0)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp leftOffset = labelWidth;
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset = labelHeight - (labelHeight * rot/180);
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp topOffset = labelHeight - (labelHeight * absRot/180);
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp props.x -= leftOffset;
5c25e6d712b880e314278e6395068dd208553b98Tripp props.y -= topOffset;
5c25e6d712b880e314278e6395068dd208553b98Tripp },
5c25e6d712b880e314278e6395068dd208553b98Tripp
5c25e6d712b880e314278e6395068dd208553b98Tripp /**
5c25e6d712b880e314278e6395068dd208553b98Tripp * Returns the transformOrigin to use for an axis label based on the position of the axis
5c25e6d712b880e314278e6395068dd208553b98Tripp * and the rotation of the label.
5c25e6d712b880e314278e6395068dd208553b98Tripp *
5c25e6d712b880e314278e6395068dd208553b98Tripp * @method _getTransformOrigin
5c25e6d712b880e314278e6395068dd208553b98Tripp * @param {Number} rot The rotation (in degrees) of the label.
5c25e6d712b880e314278e6395068dd208553b98Tripp * @return Array
5c25e6d712b880e314278e6395068dd208553b98Tripp * @protected
5c25e6d712b880e314278e6395068dd208553b98Tripp */
5c25e6d712b880e314278e6395068dd208553b98Tripp _getTransformOrigin: function(rot)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp var transformOrigin;
5c25e6d712b880e314278e6395068dd208553b98Tripp if(rot === 0)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp transformOrigin = [0, 0];
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp if(rot === 90)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp transformOrigin = [1, 0.5];
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else if (rot === -90)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp transformOrigin = [0, 0.5];
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else if(rot > 0)
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp transformOrigin = [1, 0.5];
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp else
5c25e6d712b880e314278e6395068dd208553b98Tripp {
5c25e6d712b880e314278e6395068dd208553b98Tripp transformOrigin = [0, 0.5];
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp }
5c25e6d712b880e314278e6395068dd208553b98Tripp return transformOrigin;
5c25e6d712b880e314278e6395068dd208553b98Tripp },
5c25e6d712b880e314278e6395068dd208553b98Tripp
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp /**
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Adjusts position for inner ticks.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method offsetNodeForTick
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @param {Node} cb contentBox of the axis
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp offsetNodeForTick: function(cb)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp /**
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * Assigns a height based on the size of the contents.
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp *
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp * @method setCalculatedSize
422668e1d4513bb870b8b576fd9d828c8872f074Tripp * @protected
8648721e29bb657dd5c5ff20f03e86fe50628ce6Tripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setCalculatedSize: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var host = this,
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp graphic = host.get("graphic"),
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp styles = host.get("styles"),
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp labelMargin = styles.label.margin,
e1d9c39d1eb1062e5c99cf8994b981636d8841ccTripp totalLabelSize = labelMargin.bottom + host._maxLabelSize,
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp totalTitleSize = host._totalTitleSize,
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp topTickOffset = this.get("topTickOffset"),
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp ttl = Math.round(topTickOffset + totalLabelSize + totalTitleSize);
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp if(this._explicitHeight)
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp {
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp ttl = this._explicitWidth;
5dc37e5c564d761e7c634eddf5f2e8978db2608cTripp }
68d2a3ded2307a5031fec19a1725a36821ab97a0Tripp host.set("calculatedHeight", ttl);
f99edfa53c6ad6f0caab146a750c4404fd898dc3Tripp graphic.set("y", ttl - topTickOffset);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippY.TopAxisLayout = TopAxisLayout;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp