I am feeding data to a chart from an arraycollection. When I test it by
using a literal to create the data object the chart works fine, but when
I assemble the data piece by piece, the chart fails. A correction of my
syntax would be great, and explanation even better!
I have tried creating an object, then using addItem to add it to
simpleData, and I have tried using addItem directly in simpleData, and
here I try it using a string- the result is, as you can see from the
trace output, that it was added as an array, not an object.... at least
thats what *I* see.
#################################################
#################3 This works: ####################
simpleData = new ArrayCollection([]);
simpleData.addItem({name:"se2", inpps:2233, refresh:3000, outpps:7799,
conns:2211, inbps:1144, inpkts:3322, outbps:2233, outpkts:4433,
inbytes:4455, outbytes:5544, cps:6655});
trace("ServerPopUp:makeChart2 simpledata THAT WORKS: = " +
ObjectUtil.toString(simpleData) );
ServerPopUp:makeChart2 simpledata THAT WORKS: =
(mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 1
list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
[0] (Object)#3
conns = 2211
cps = 6655
inbps = 1144
inbytes = 4455
inpkts = 3322
inpps = 2233
name = "se2"
outbps = 2233
outbytes = 5544
outpkts = 4433
outpps = 7799
refresh = 3000
uid = "CBEA58EB-CF06-51A8-8887-B289C8E48C2A"
sort = (null)
source = (Array)#2
################## This does not work: ################
simpleData = new ArrayCollection([]);
var st:String = new String();
#left out the loops here for clarity #
st += '{' + "name:" + '"' + statNode.name + '", ' ;
# looped here through data #
var elname:String = element.name();
var elvalue:Number = element.valueOf() ;
st += elname + ":" + elvalue + ", " ;
var newst:String = st.slice(0, st.length-2 ); ////cuts off last white
space and comma
newst += '}' ;
simpleData.addItem( newst as Object ) ;
trace("ServerPopUp:makeChart simpledata: = " +
ObjectUtil.toString(simpleData) );
ServerPopUp:makeChart simpledata: = (mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 1
list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
[0] "{name:"se2", inpps:2233, refresh:3000, outpps:7799,
conns:2211, inbps:1144, inpkts:3322, outbps:2233, outpkts:4433,
inbytes:4455, outbytes:5544, cps:6655}"
uid = "9543B87D-14F5-0BC6-E2F0-B289C8EC32FC"
sort = (null)
source = (Array)#2
#####
thanks
John