⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 numericaxis.as

📁 拓扑图基于SNMP数据采集模块的设计和实现
💻 AS
📖 第 1 页 / 共 2 页
字号:
package com.yahoo.astra.fl.charts.axes{	import com.yahoo.astra.fl.charts.series.ISeries;	import com.yahoo.astra.fl.utils.UIComponentUtil;	import com.yahoo.astra.utils.NumberUtil;		import flash.utils.Dictionary;		/**	 * An axis type representing a numeric range from minimum to maximum	 * with major and minor divisions.	 * 	 * @author Josh Tynjala	 */	public class NumericAxis extends BaseAxis implements IAxis, IOriginAxis, IStackingAxis	{			//--------------------------------------	//  Static Properties	//--------------------------------------			/**		 * A magic number specifying an ideal minimum number of		 * pixels between each tick/line/label on a major unit.		 * Used to calculate the major unit if it is not set by		 * the developer. 		 */		private static const IDEAL_PIXELS_BETWEEN_MAJOR_POSITIONS:Number = 70;				/**		 * A magic number specifying an ideal minimum number of		 * pixels between each tick/line/label on a minor unit.		 * Used to calculate the minor unit if it is not set by		 * the developer. 		 */		private static const IDEAL_PIXELS_BETWEEN_MINOR_POSITIONS:Number = 30;			//--------------------------------------	//  Constructor	//--------------------------------------			/**		 * Constructor.		 */		public function NumericAxis()		{		}	//--------------------------------------	//  Properties	//--------------------------------------				/**		 * @private		 * The multiplier used to calculate the position on the renderer from an		 * axis value.		 */		protected var positionMultiplier:Number = 0;				/**		 * @private		 * Storage for the minimum value.		 */		private var _minimum:Number = 0;				/**		 * @private		 * Indicates whether the minimum bound is user-defined or generated by the axis.		 */		private var _minimumSetByUser:Boolean = false;				/**		 * The minimum value displayed on the axis. By default, this value is generated		 * by the axis itself. If the user defines this value, the axis will skip this		 * automatic generation. To enable this behavior again, set this property to NaN.		 */		public function get minimum():Number		{			return this._minimum;		}				/**		 * @private		 */		public function set minimum(value:Number):void		{			this._minimum = value;			this._minimumSetByUser = !isNaN(value);		}			/**		 * @private		 * Storage for the maximum value.		 */		private var _maximum:Number = 100;				/**		 * @private		 * Indicates whether the maximum bound is user-defined or generated by the axis.		 */		private var _maximumSetByUser:Boolean = false;				/**		 * The maximum value displayed on the axis. By default, this value is generated		 * by the axis itself. If the user defines this value, the axis will skip this		 * automatic generation. To enable this behavior again, set this property to NaN.		 */		public function get maximum():Number		{			return this._maximum;		}				/**		 * @private		 */		public function set maximum(value:Number):void		{			this._maximum = value;			this._maximumSetByUser = !isNaN(value);		}			//-- Units			/**		 * @private		 * Storage for the major unit.		 */		private var _majorUnit:Number = 10;				/**		 * @private		 * Indicates whether the major unit is user-defined or generated by the axis.		 */		private var _majorUnitSetByUser:Boolean = false;				/**		 * The major unit at which new ticks and labels are drawn. By default, this value		 * is generated by the axis itself. If the user defines this value, the axis will		 * skip the automatic generation. To enable this behavior again, set this property		 * to NaN.		 */		public function get majorUnit():Number		{			return this._majorUnit;		}				/**		 * @private		 */		public function set majorUnit(value:Number):void		{			this._majorUnit = value;			this._majorUnitSetByUser = !isNaN(value);		}			/**		 * @private		 * Storage for the minor unit.		 */		private var _minorUnit:Number = 5;				/**		 * @private		 * Indicates whether the minor unit is user-defined or generated by the axis.		 */		private var _minorUnitSetByUser:Boolean = false;				/**		 * The minor unit at which new ticks are drawn. By default, this value		 * is generated by the axis itself. If the user defines this value, the axis will		 * skip the automatic generation. To enable this behavior again, set this property		 * to NaN.		 */		public function get minorUnit():Number		{			return this._minorUnit;		}				/**		 * @private		 */		public function set minorUnit(value:Number):void		{			this._minorUnit = value;			this._minorUnitSetByUser = !isNaN(value);		}				/**		 * @inheritDoc		 */		public function get origin():Object		{			var origin:Number = 0;			if(this.scale == ScaleType.LOGARITHMIC)			{				origin = 1;			}						origin = Math.max(origin, this.minimum);			origin = Math.min(origin, this.maximum);			return origin;		}				/**		 * @private		 * Storage for the stackingEnabled property.		 */		private var _stackingEnabled:Boolean = false;				/**		 * @inheritDoc		 */		public function get stackingEnabled():Boolean		{			return this._stackingEnabled;		}				/**		 * @private		 */		public function set stackingEnabled(value:Boolean):void		{			this._stackingEnabled = value;		}			/**		 * @private		 * Storage for the alwaysShowZero property.		 */		private var _alwaysShowZero:Boolean = true;				/**		 * If true, the axis will attempt to keep zero visible at all times.		 * If both the minimum and maximum values displayed on the axis are		 * above zero, the minimum will be reset to zero. If both minimum and		 * maximum appear below zero, the maximum will be reset to zero. If		 * the minimum and maximum appear at positive and negative values		 * respectively, zero is already visible and the axis scale does not		 * change.		 * 		 * <p>This property has no affect if you manually set the minimum and		 * maximum values of the axis.</p>		 */		public function get alwaysShowZero():Boolean		{			return this._alwaysShowZero;		}				/**		 * @private		 */		public function set alwaysShowZero(value:Boolean):void		{			this._alwaysShowZero = value;		}			/**		 * @private		 * Storage for the snapToUnits property.		 */		private var _snapToUnits:Boolean = true;				/**		 * If true, the labels, ticks, gridlines, and other objects will snap to		 * the nearest major or minor unit. If false, their position will be based		 * on the minimum value.		 */		public function get snapToUnits():Boolean		{			return this._snapToUnits;		}				/**		 * @private		 */		public function set snapToUnits(value:Boolean):void		{			this._snapToUnits = value;		}				/**		 * @private		 * Storage for the scale property.		 */		private var _scale:String = ScaleType.LINEAR;				/**		 * The type of scaling used to display items on the axis.		 * 		 * @see com.yahoo.astra.fl.charts.ScaleType		 */		public function get scale():String		{			return this._scale;		}				/**		 * @private		 */		public function set scale(value:String):void		{			this._scale = value;		}				/**		 * @private		 */		private var _dataMinimum:Number = NaN;				/**		 * @private		 */		private var _dataMaximum:Number = NaN;				//--------------------------------------	//  Public Methods	//--------------------------------------			/**		 * @inheritDoc		 */		public function valueToLocal(data:Object):Number		{			if(data == null)			{				//bad data. a properly-designed renderer will not draw this.				return NaN;			}						var position:Number = 0;						if(this.scale == ScaleType.LINEAR)			{				position = (Number(data) - this.minimum) * this.positionMultiplier;			}			else			{				var logOfData:Number = Math.log(Number(data));				var logOfMinimum:Number = Math.log(this.minimum);				position = (logOfData - logOfMinimum) * this.positionMultiplier;			}						if(this.reverse)			{				position = this.renderer.length - position;			}						//the vertical axis has its origin on the bottom			if(this.renderer is ICartesianAxisRenderer && ICartesianAxisRenderer(this.renderer).orientation == AxisOrientation.VERTICAL)			{				position = this.renderer.length - position;			}						return Math.round(position);		}			/**		 * @inheritDoc		 */		public function stack(top:Object, ...rest:Array):Object		{			var numericValue:Number = Number(top);			var negative:Boolean = false;			if(numericValue < 0)			{				negative = true;			}						var restCount:int = rest.length;			for(var i:int = 0; i < restCount; i++)			{				var currentValue:Number = Number(rest[i]);				if(negative && currentValue < 0)				{					numericValue += currentValue;				}				else if(!negative && currentValue > 0)				{					numericValue += currentValue;				}			}			return numericValue;		}			/**		 * @inheritDoc		 */		public function updateScale(data:Array):void

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -