Hi,

Your suggestion finally got me going on the right track.
Part of the issue was definitely the single item being
deserialized as ObjectProxy instead of ArrayCollection.
I used some ideas from:
http://casario.blogs.com/mmworld/2006/07/arraycollection.html

In particular the sample code pasted below from the url article
above. Instead of binding directly to the httpservice, I use
the result= parameter of the httpservice to call a function.
The function checks if the returned value is an objectproxy,
and if it is it adds it to a new ArrayCollection.

In addition, the chart wasn't working properly with only one
datapoint because the chart axis apparently needs at least
two datapoints to autosize itself properly. So what I decided
to do was to add two "dummy" datapoints with value 0, one
before and one after the single datapoint, so that the chart
axis would be sized properly and so that the single datapoint
would be centered on the screen.

=========

"This is the callback function I use for HTTPService. You can easily
guess the XML format.

screensList is an ArrayCollection
screensResult is the HTTPService

private function http_result( event :ResultEvent ) :void {

if( screensResult.lastResult.screens == null ) {
numScreensLabel.text = "No. of screens: 0"
}
else if( screensResult.lastResult.screens.screen is ObjectProxy ) {
numScreensLabel.text = "No. of screens: 1"
screensList = new ArrayCollection(
[screensResult.lastResult.screens.screen] );
}
else {
screensList = screensResult.lastResult.screens.screen as ArrayCollection;
numScreensLabel.text = "No. of screens: " + screensList.length;
}
}


--- In [email protected], "Clint Modien" <[EMAIL PROTECTED]> wrote:
>
> This is a pretty common problem people run into...
> 
> When you do an xml get from a service... if you get back 2 or more
elements
> it will be created as an array in AS2/AS3.
> 
> But when that same service returns one element it will be
deserialized as a
> single AS2/AS3 OBJECT.
> 
> Import mx.utils.ArrayUtil and then run the result through
ArrayUtil.toArray()
> first... like this:
> 
> <mx:ColumnChart
> dataProvider="{ArrayUtil.toArray(
> httpGetYearlyPatentStats.lastResult.rsp.statistic)}">
> 
> 
> On 2/8/07, coderdude2 <[EMAIL PROTECTED]> wrote:
> >
> >   Hi,
> >
> > I'm using a column chart with my application. Works fine when
> > displaying two or more columns, but if the dataProvider contains data
> > for only one column, the column is not displayed.
> >
> > The only way I found to display it is to use a CategoryAxis, but that
> > won't work for me because it skips missing years (if the data has
> > values for 1984 and 1987 let's say, CategoryAxis doesn't know to
> > display all the years in between on the axis).
> >
> > Here's the chart setup I'm using:
> >
> > <mx:ColumnChart itemClick="chartClickHandler(event)"
> > id="colchartYearlyPatentStats" maxColumnWidth="20" left="5" top="5"
> > bottom="5" right="5" showDataTips="true"
> > dataProvider="{httpGetYearlyPatentStats.lastResult.rsp.statistic}"
> > >
> > <mx:series>
> > <mx:ColumnSeries displayName="" xField="year" yField="count" />
> > </mx:series>
> > <mx:horizontalAxis>
> > <mx:LinearAxis maximumLabelPrecision="1" baseAtZero="false"
> > minorInterval="0" interval="1" alignLabelsToInterval="true"/>
> > </mx:horizontalAxis>
> > </mx:ColumnChart>
> >
> > Thanks for any help!
> >
> >  
> >
>


Reply via email to