Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-15-2011, 08:17 AM   #1
flexable
Member
 
Join Date: May 2010
Location: india
Posts: 68
Default problem in flex charts

this is my code..my application takes in a customer no input and shows a graph of arrival and departure of cutomers on some calcualtion done...i am unable to put the departure line...arrival line is coming up.
image at- http://asdfshare.com/tycoix6jm7iq/snap.bmp.html
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
	<![CDATA[
		import mx.collections.ArrayCollection;
		
		     public var ia:Array=new Array(0,125,250,375,500,625,750,825,1000);// inter arrival cumulative
       
             public var st:Array=new Array(100,300,600,850,950,1000);//service cumulative
   
             public var interarrival:Array=new Array();
             public var service:Array=new Array();
             public var arrival:Array= new Array();
             public var departure:Array= new Array();
             //public var display:ArrayCollection= new ArrayCollection([{no:1,Departure:10,arriva:20},{no:2,Departure:23,arriva:20},{no:3,Departure:34,arriva:43}]);
              public var display:ArrayCollection= new ArrayCollection([{no:0,Departure:0,arriva:0}]);
             public var i:Number;// for the outer loop of no of customers
             public var n:Number;
             public var t:Number;//for clock
             public var iaval:Number;//interarrival lloop increment
             public var stval:Number;//service loop increment
             public var d:Number;
             public var p:Number;
             public var l:Number;
             public var m:Number;
             public var f:Number;
             public var q:Number=1;//arrival cal
             public var nn:int;//used in calculating arrival
             public var arrive:int;
             public var depart:int;
             public var wait:Boolean;
             public var idle:Boolean;
             public var z:int;
             public var xx:int=1;
             public var v:int=1;
             public var c:int;
             
        
        
        public function randomNumber(low:Number, high:Number):Number//random function
         {
        return Math.floor(Math.random() * (1+high-low)) + low;
         }
       
         
         public function calrand():void
         {
         	n=new Number(inp.text);//taking user input for no of users
         	arrival[0]=0;//setting arrival initial
         	trace("service time,inter arrival, arrival time,departure time");
         	  
            for( i=0;i<n;i++)
         {
         	var ianum:Number=randomNumber(0,999);
            var sernum:Number= randomNumber(0,999);
          //  trace(ianum,sernum);//tracing random numbers
            
            //calculating the interarrival time
            if(ianum>0&&ianum<125)
            iaval=1;
            else if(ianum>125&&ianum<250)
            iaval=2;
            else if(ianum>250&&ianum<375)
            iaval=3;
            else if(ianum>375&&ianum<500)
            iaval=4;
            else if(ianum>500&&ianum<625)
            iaval=5;
            else if(ianum>625&&ianum<750)
            iaval=6;
            else if(ianum>750&&ianum<825)
            iaval=7;
            else 
            iaval=8;
            
            interarrival[d++]=iaval;
            nn=nn+iaval;//for arrival
            arrival[q++]=nn//putting in arrival array
           
            
            
            //calculating the service time
            
            if(sernum>0&&sernum<100)
            stval=1;
            else if(sernum>100&&sernum<300)
            stval=2;
            else if(sernum>300&&sernum<600)
            stval=3;
            else if(sernum>600&&sernum<850)
            stval=4;
            else if(sernum>850&&sernum<950)
            stval=5;
            else
            stval=6;
            
            service[p++]=stval;
            departure[f++]=arrival[q-2]+stval;//departure time calculated
        
            trace(service[p-1],interarrival[d-1],arrival[q-2],departure[f-1]);
            
           
           // trace(stval);
            
           // trace(iaval,stval);//tracing 
  
         	
         }
         for(var ii:int=1;ii<=n;ii++)
            {
            	display.addItemAt({no:ii,Departure:departure[ii],arriva:arrival[ii]},ii);
            	trace(display.getItemAt(ii));
            	  
            }
         
         var ldep:int=departure[f-1];
        
         trace(ldep);//coorect last departure fr clock
  
           arrive++;
       for(t=0;t<ldep;t++)//clock loop
        {
        	trace("AT CLOCK =",t);
        	
        if(t==arrival[z])
        	{
            arrive=arrive+1;
            z++;
            trace("naval");
           
        	}
     /*   else if(arrival[x]<=departure[x-1])
        	{//departure will take time n a process arrives
        	wait=true;
        	trace("wait");
        	x++;
        	}
       else  if(arrival[v-1]>=departure[v])
        	{//arrival has nt come and the last process ends
        	idle=true;
        	trace("idle");
        	v++;
        	}
        else if(t==departure[c])
        	{
        	arrive=arrive-1;
        	depart=depart+1;
        	c++;
        	}*/
        else
       // naval(); 
        
        
        
        linechart.dataProvider=display;//imp line... providing data to chart
        
        trace("arrival=",arrive,"waiting=",wait,"idle=",idle,"departure=",depart);
        wait=false;
        idle=false;
       
        }
         
        
  	 
         }
         public function naval():void
         
         {
         	trace("i am naval joshi");
         if(arrival[xx]<=departure[xx-1])
        	{//departure will take time n a process arrives
        	wait=true;
        	trace("wait");
        	xx++;
        	}
       else  if(arrival[v-1]>=departure[v])
        	{//arrival has nt come and the last process ends
        	idle=true;
        	trace("idle");
        	v++;
        	}
        else if(t==departure[c])
        	{
        	arrive=arrive-1;
        	depart=depart+1;
        	c++;
        	}
        	else
        	trace("continue");
         }
         
       
            
       
         
         
         
         	
        
	]]>
</mx:Script>
	<mx:Label x="17" y="116" text="enter the no of users" width="160" height="38"/>
	<mx:Button x="98" y="203" label="Button" id="btn" click="calrand();"/>
	<mx:TextInput x="236" y="114" id="inp"/>
	  <mx:Stroke id = "s1" color="blue" weight="2"/>
	     <mx:Stroke id = "s2" color="green" weight="2"/>
	 <mx:LineChart id="linechart" height="100%" width="682"
            paddingLeft="5" paddingRight="5" 
            showDataTips="true"  x="483">
                
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="no"/>
            </mx:horizontalAxis>

            <mx:series>
             <mx:LineSeries yField="Departure" form="curve" displayName="Departure" lineStroke="{s2}"/>
                <mx:LineSeries yField="arriva" form="curve" displayName="Arrival" lineStroke="{s1}"/>
                    </mx:series>
        </mx:LineChart>
        <mx:Legend dataProvider="{linechart}" x="380" y="10" width="95" height="65"/>

	
</mx:WindowedApplication>
the problem seems to be with this portion..the departure array dosent seems to populate the collection..but y??
Code:
  for(var ii:int=1;ii<=n;ii++)
            {
            	display.addItemAt({no:ii,Departure:departure[ii],arriva:arrival[ii]},ii);
            	trace(display.getItemAt(ii));
            	  
            }

Last edited by flexable; 10-15-2011 at 08:22 AM.
flexable is offline   Reply With Quote
Old 10-17-2011, 02:01 PM   #2
flexable
Member
 
Join Date: May 2010
Location: india
Posts: 68
Default waiting for reply..

still waiting fr replys guyss...
flexable is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:45 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.