flex 之折线图2

阅读更多
该博文转自 “百度知道”


   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
   xmlns:chartClasses="views.charts.chartClasses.*"
   applicationComplete="onInit()"      
   creationComplete="creationBtnHandler(event)">









































































/* 翻译之前跳过加水印步骤 */
[Frame(extraClass="mx.charts.chartClasses.ChartsLicenseHandler")]
import mx.formatters.DateFormatter;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.controls.Alert;
import mx.charts.CategoryAxis;
import mx.charts.chartClasses.IAxis;

[Bindable]
private var array:ArrayCollection = new ArrayCollection();

//private var _DropShadowFilter:DropShadowFilter = new DropShadowFilter(2, 45, 0x000000, 0.7, 2, 2, 0.65, 3, false, false);
[Bindable]
private function linearAxis_labelFunc(item:Object, prevValue:Object, axis:IAxis):String {
return currFormatter.format(item);
}

private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String {
return String(item);
}

protected function hsb_changeHandler(event:Event):void
{
setDataProvider();
}

protected function setDataProvider():void
{

var j:int = int(hsb.scrollPosition);

array.removeAll();

var count:int =0;

for (var i:int = j; (i {
array.addItem(dp.getItemAt(i));
}
mychart.dataProvider = array;
}

private function onInit():void

{
Alert.show("数据总数:"+dp1.length.toString());
//      logBox.text = "";
//             var currentParamIndex:uint = 1;
//      for(var parameterName:String in parameters)
//               {
//                 logBox.text += "Parameter #"+currentParamIndex + ": ";
//                  logBox.text += parameterName + " " + parameters[parameterName] + "\n";
//                 currentParamIndex++;
//                 }


private function init(evt:Event):void {
var chart:LineChart = evt.currentTarget as LineChart;
seriesFilterArr = chart.seriesFilters;
}

private function checkBox_click(evt:MouseEvent):void {
var len:uint = mychart.seriesFilters.length;
if (len > 0) {
mychart.seriesFilters = [];
} else {
mychart.seriesFilters = seriesFilterArr;
}
}


//实现曲线图的拖拽
private var downXY:Point=new Point();
private var   upXY:Point=new Point();
private function mouseEventFunc(evt:MouseEvent):void {
switch (evt.type) {
case "mouseDown" :downXY.x = mouseX;downXY.y = mouseY;evt.currentTarget.startDrag();
break;
case "mouseUp" :upXY.x = mouseX;upXY.y = mouseY;evt.currentTarget.stopDrag();
break;
default:
break;}}


//页面加载完毕后执行事件注册
private function creationBtnHandler(e:Event):void{
mychart.addEventListener(MouseEvent.MOUSE_UP,mouseEventFunc);
mychart.addEventListener(MouseEvent.MOUSE_DOWN,mouseEventFunc);
}

]]>





label="过滤"
labelPlacement="left"
click="checkBox_click(event);" />


  y="51"
  width="1145"
  height="494"
  dataProvider="{array}"
  paddingLeft="5"
  paddingRight="5"
  seriesFilters="[]"
  showDataTips="true"
  creationComplete="init(event);">


















   maxScrollPosition="34" minScrollPosition="0" pageScrollSize="5" repeatDelay="5"
   repeatInterval="5" scroll="hsb_changeHandler(event);" scrollPosition="10"/> 


你可能感兴趣的:(flex)