LeftAxisLayout.js revision 6aa3a8d9176704373c2e24b0530b508f643fe6a0
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * Algorithmic strategy for rendering a left axis.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @class LeftAxisLayout
d048f1c15089c16b8ca1b264513a2f92ff86e703JazzyNico * @constructor
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNicoLeftAxisLayout = function() {};
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Default margins for text fields.
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @method _getDefaultMargins
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @return Object
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Sets the length of the tick on either side of the axis line.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method setTickOffset
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico case "inside" :
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico case "outside" :
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico case "cross":
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Draws a tick
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method drawTick
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param {Object} pt Point on the axis in which the tick will intersect.
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @param {Object} tickStyle Hash of properties to apply to the tick.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Calculates the coordinates for the first point on an axis.
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @method getLineStart
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @return {Object}
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Calculates the point for a label.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method getLabelPoint
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param {Object} point Point on the axis in which the tick will intersect.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @return {Object}
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico return {x:point.x - this.get("leftTickOffset"), y:point.y};
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Updates the value for the `maxLabelSize` for use in calculating total size.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method updateMaxLabelSize
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param {HTMLElement} label to measure
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
ba93101fe1cf68c34d71b5406224a3e1be4fe6e1JazzyNico label.style.filter = 'progid:DXImageTransform.Microsoft.Matrix(M11=' + m11 + ' M12=' + m12 + ' M21=' + m21 + ' M22=' + m22 + ' sizingMethod="auto expand")';
ba93101fe1cf68c34d71b5406224a3e1be4fe6e1JazzyNico host.set("maxLabelSize", Math.max(host.get("maxLabelSize"), label.offsetWidth));
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico max = (cosRadians * label.offsetWidth) + (sinRadians * label.offsetHeight);
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico host.set("maxLabelSize", Math.max(host.get("maxLabelSize"), max));
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Rotate and position title.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method positionTitle
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param {HTMLElement} label to rotate position
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico max = (cosRadians * labelWidth) + (sinRadians * labelHeight);
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico topOffset -= ((sinRadians * labelWidth) + (cosRadians * labelHeight))/2;
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico leftOffset += Math.min(labelHeight, (sinRadians * labelHeight));
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico topOffset += (sinRadians * labelWidth)/2 - (cosRadians * labelHeight)/2;
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico max = (cosRadians * labelWidth) + (sinRadians * labelHeight);
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico topOffset -= ((sinRadians * labelWidth) + (cosRadians * labelHeight))/2;
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Rotate and position labels.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method positionLabel
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @param {HTMLElement} label to rotate position
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param {Object} pt hash containing the x and y coordinates in which the label will be positioned
40e5cf3e8f0ddda79b1650df77d0f847a22822bfJazzyNico * @protected
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico leftOffset = (cosRadians * labelWidth) + (labelHeight * rot/90);
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico topOffset -= (sinRadians * labelWidth) + (cosRadians * (labelHeight * 0.5));
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico leftOffset = (cosRadians * labelWidth) + (absRot/90 * labelHeight);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico label.style.left = Math.round((pt.x + this._titleSize + maxLabelSize) - leftOffset) + "px";
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico leftOffset -= (cosRadians * labelWidth) + (sinRadians * labelHeight);
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico topOffset += (sinRadians * labelWidth) - (cosRadians * (labelHeight * 0.6));
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico topOffset -= (sinRadians * labelWidth) + (cosRadians * (labelHeight * 0.6));
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico props.x = Math.round(host.get("maxLabelSize") + leftOffset);
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Calculates the size and positions the content elements.
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @method setSizeAndPosition
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @protected
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * Adjust the position of the Axis widget's content box for internal axes.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method offsetNodeForTick
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @param {Node} cb Content box of the Axis.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * Sets the width of the axis based on its contents.
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico * @method setCalculatedSize
646e07284c35ae746e8a0cf0698098e116ebb5a3JazzyNico * @protected
88395eed42de4d59f54795b60c8c0a7ab881e153JazzyNico ttl = Math.round(this._titleSize + tickOffset + max + label.margin.right);