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

📄 cartesianchart.as

📁 拓扑图基于SNMP数据采集模块的设计和实现
💻 AS
📖 第 1 页 / 共 4 页
字号:
		{			lineWeight: "verticalAxisGridLineWeight",			lineColor: "verticalAxisGridLineColor",			showLines: "showVerticalAxisGridLines",						minorLineWeight: "verticalAxisMinorGridLineWeight",			minorLineColor: "verticalAxisMinorGridLineColor",			showMinorLines: "showVerticalAxisMinorGridLines",						fillColors: "verticalAxisGridFillColors",			fillAlphas: "verticalAxisGridFillAlphas"		}			//--------------------------------------	//  Class Methods	//--------------------------------------			/**		 * @copy fl.core.UIComponent#getStyleDefinition()		 */		public static function getStyleDefinition():Object		{			return mergeStyles(defaultStyles, Chart.getStyleDefinition());		}			//--------------------------------------	//  Constructor	//--------------------------------------			/**		 * Constructor.		 */		public function CartesianChart()		{			super();		}			//--------------------------------------	//  Properties	//--------------------------------------				/**		 * @private		 * Storage for the contentBounds property.		 */		protected var _contentBounds:Rectangle = new Rectangle();			/**		 * The rectangular bounds where the cartesian chart's data is drawn.		 */		public function get contentBounds():Rectangle		{			return this._contentBounds;		}				/**		 * @private		 */		protected var horizontalGridLines:IGridLinesRenderer;				/**		 * @private		 */		protected var verticalGridLines:IGridLinesRenderer;				/**		 * @private		 */		protected var verticalMinorGridLines:Sprite;				/**		 * @private		 * The visual representation of the horizontal axis.		 */		protected var horizontalAxisRenderer:ICartesianAxisRenderer;				/**		 * @private		 * Storage for the horizontalAxis property.		 */		private var _horizontalAxis:IAxis;				/**		 * The axis representing the horizontal range.		 */		public function get horizontalAxis():IAxis		{			return this._horizontalAxis;		}				/**		 * @private		 */		public function set horizontalAxis(axis:IAxis):void		{			if(this._horizontalAxis != axis)			{				this._horizontalAxis = axis;				this._horizontalAxis.chart = this;								this.invalidate("axes");			}		}				/**		 * @private		 * The visual representation of the horizontal axis.		 */		protected var verticalAxisRenderer:ICartesianAxisRenderer;				/**		 * @private		 * Storage for the verticalAxis property.		 */		private var _verticalAxis:IAxis;				/**		 * The axis representing the vertical range.		 */		public function get verticalAxis():IAxis		{			return this._verticalAxis;		}				/**		 * @private		 */		public function set verticalAxis(axis:IAxis):void		{			if(this._verticalAxis != axis)			{				this._verticalAxis = axis;				this._verticalAxis.chart = this;				this.invalidate("axes");			}		}		//-- Data				/**		 * @private		 * Storage for the horizontalField property.		 */		private var _horizontalField:String = "category";				[Inspectable(defaultValue="category",verbose=1)]		/**		 * If the items displayed on the chart are complex objects, the horizontalField string		 * defines the property to access when determining the x value.		 */		public function get horizontalField():String		{			return this._horizontalField;		}				/**		 * @private		 */		public function set horizontalField(value:String):void		{			if(this._horizontalField != value)			{				this._horizontalField = value;				this.invalidate(InvalidationType.DATA);			}		}				/**		 * @private		 * Storage for the verticalField property.		 */		private var _verticalField:String = "value";				[Inspectable(defaultValue="value",verbose=1)]		/**		 * If the items displayed on the chart are complex objects, the verticalField string		 * defines the property to access when determining the y value.		 */		public function get verticalField():String		{			return this._verticalField;		}				/**		 * @private		 */		public function set verticalField(value:String):void		{			if(this._verticalField != value)			{				this._verticalField = value;				this.invalidate(InvalidationType.DATA);			}		}			//-- Titles				/**		 * @private		 * Storage for the horizontalAxisTitle property.		 */		private var _horizontalAxisTitle:String = "";				[Inspectable(defaultValue="")]		/**		 * The title text displayed on the horizontal axis.		 */		public function get horizontalAxisTitle():String		{			return this._horizontalAxisTitle;		}				/**		 * @private		 */		public function set horizontalAxisTitle(value:String):void		{			if(this._horizontalAxisTitle != value)			{				this._horizontalAxisTitle = value;				this.invalidate(InvalidationType.DATA);				this.invalidate("axes");			}		}				/**		 * @private		 * Storage for the verticalAxisTitle property.		 */		private var _verticalAxisTitle:String = "";				[Inspectable(defaultValue="")]		/**		 * The title text displayed on the horizontal axis.		 */		public function get verticalAxisTitle():String		{			return this._verticalAxisTitle;		}				/**		 * @private		 */		public function set verticalAxisTitle(value:String):void		{			if(this._verticalAxisTitle != value)			{				this._verticalAxisTitle = value;				this.invalidate(InvalidationType.DATA);				this.invalidate("axes");			}		}			//-- Category names				/**		 * @private		 * Storage for the categoryNames property.		 */		private var _explicitCategoryNames:Array;				[Inspectable]		/**		 * The names of the categories displayed on the category axis. If the		 * chart does not have a category axis, this value will be ignored.		 */		public function get categoryNames():Array		{			if(this._explicitCategoryNames && this._explicitCategoryNames.length > 0)			{				return this._explicitCategoryNames;			}			else if(this.horizontalAxis is CategoryAxis)			{				return CategoryAxis(this.horizontalAxis).categoryNames;			}			else if(this.verticalAxis is CategoryAxis)			{				return CategoryAxis(this.verticalAxis).categoryNames;			}			return null;		}				/**		 * @private		 */		public function set categoryNames(value:Array):void		{			if(this._explicitCategoryNames != value)			{				this._explicitCategoryNames = value;				this.invalidate(InvalidationType.DATA);				this.invalidate("axes");			}		}				/**		 * @private		 * Storage for the overflowEnabled property.		 */		private var _overflowEnabled:Boolean = false;				[Inspectable(defaultValue=false,verbose=1)]		/**		 * If false, which is the default, the axes will be resized to fit within the defined		 * bounds of the plot area. However, if set to true, the axes themselves will grow to		 * fit the plot area bounds and the labels and other items that normally cause the		 * resize will be drawn outside.		 */		public function get overflowEnabled():Boolean		{			return this._overflowEnabled;		}				/**		 * @private		 */		public function set overflowEnabled(value:Boolean):void		{			if(this._overflowEnabled != value)			{				this._overflowEnabled = value;				this.invalidate("axes");			}		}			//--------------------------------------	//  Public Methods	//--------------------------------------			/**		 * @inheritDoc		 */		public function itemToPosition(series:ISeries, itemIndex:int):Point		{			var horizontalValue:Object = this.itemToAxisValue(series, itemIndex, this.horizontalAxis);			var xPosition:Number = this.horizontalAxis.valueToLocal(horizontalValue);						var verticalValue:Object = this.itemToAxisValue(series, itemIndex, this.verticalAxis);			var yPosition:Number = this.verticalAxis.valueToLocal(verticalValue);						return new Point(xPosition, yPosition);		}				/**		 * @private		 */		public function itemToAxisValue(series:ISeries, itemIndex:int, axis:IAxis, stack:Boolean = true):Object		{			if(!stack || !ChartUtil.isStackingAllowed(axis, series))			{				var item:Object = series.dataProvider[itemIndex];				var valueField:String = this.axisAndSeriesToField(axis, series);				return item[valueField];			}						var type:Class = UIComponentUtil.getClassDefinition(series);			var stackAxis:IStackingAxis = IStackingAxis(axis);			var stackValue:Object;			var allSeriesOfType:Array = ChartUtil.findSeriesOfType(series, this);			var seriesIndex:int = allSeriesOfType.indexOf(series);			var values:Array = [];			for(var i:int = 0; i <= seriesIndex; i++)			{				var stackedSeries:IStackedSeries = IStackedSeries(allSeriesOfType[i]);				item = stackedSeries.dataProvider[itemIndex];				valueField = this.axisAndSeriesToField(stackAxis, stackedSeries);				values.unshift(item[valueField]);			}						if(values.length > 0)			{				stackValue = stackAxis.stack.apply(stackAxis, values);			}			return stackValue;		}				/**		 * Sets a style on the horizontal axis.		 */		public function setHorizontalAxisStyle(name:String, value:Object):void		{			this.setComplexStyle("horizontalAxisStyles", name, value);		}				/**		 * Sets a style on the vertical axis.		 */		public function setVerticalAxisStyle(name:String, value:Object):void		{			this.setComplexStyle("verticalAxisStyles", name, value);		}				/**		 * Sets a style on the horizontal axis grid lines.		 */		public function setHorizontalAxisGridLinesStyle(name:String, value:Object):void		{			this.setComplexStyle("horizontalAxisGridLinesStyles", name, value);		}				/**		 * Sets a style on the vertical axis grid lines.		 */		public function setVerticalAxisGridLinesStyle(name:String, value:Object):void		{			this.setComplexStyle("verticalAxisGridLinesStyles", name, value);		}			//--------------------------------------	//  Protected Methods	//--------------------------------------		 		/**		 * @private		 */		override protected function draw():void		{			var dataInvalid:Boolean = this.isInvalid(InvalidationType.DATA);			var stylesInvalid:Boolean = this.isInvalid(InvalidationType.STYLES);			var sizeInvalid:Boolean = this.isInvalid(InvalidationType.SIZE);			var axesInvalid:Boolean = this.isInvalid("axes")						super.draw();						if(stylesInvalid)			{				this.updateRenderers();			}						if(sizeInvalid || dataInvalid || stylesInvalid || axesInvalid)			{				this.drawAxes();									//the series display objects are dependant on the axes, so all series redraws must				//happen after the axes have redrawn				this.drawSeries();				}						this.updateLegend();		}				/**		 * @private		 * Make sure no numeric points exist. Convert to objects compatible with the axes.		 */		override protected function refreshSeries():void		{			super.refreshSeries();						var numericAxis:IAxis = this.horizontalAxis;			var otherAxis:IAxis = this.verticalAxis;			if(this.verticalAxis is NumericAxis)			{				numericAxis = this.verticalAxis;				otherAxis = this.horizontalAxis;			}									var seriesCount:int = this.series.length;			for(var i:int = 0; i < seriesCount; i++)			{				var currentSeries:ISeries = this.series[i] as ISeries;								var numericField:String = this.axisAndSeriesToField(numericAxis, currentSeries);				var otherField:String = this.axisAndSeriesToField(otherAxis, currentSeries);

⌨️ 快捷键说明

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