Hey guys, I'm having a problem I think may be a bug.. It has to do
with the category axis on a column chart when using XMLListCollection
as a dataProvider.

Basically what I see is that if I use an actual data set (one of the
data providers from a series) as the category Axis dataProvider, the
labels show correctly. However if I pass an XMLList containing a list
of Simple elements containing the strings (or even just an array of
strings) for the category axis dataProvider, the labels don't show at
all. The documentation for CategoryAxis says:

"The dataProvider property can accept either an array of strings or an
array of records (objects) with a property specifying the category
name. If you specify a categoryField property, the CategoryAxis
assumes the dataProvider is an array of Objects. If cateogryField is
null, the CategoryAxis assumes dataProvider is an array of Strings."

It seems like this should work. I cannot seem to make it work.

Below you can find a sample application and populateChart function
which demonstrates the problem. I have commented out the working two
lines, and the other two lines which exibit the problem are below it.

Thanks in advance,
Thunder
__________________________


<?xml version="1.0" encoding="utf-8"?>
<mx:Application
   width="100%" height="100%"
   xmlns:mx="http://www.macromedia.com/2005/mxml"; 
   xmlns:root="*">
        
<mx:ColumnChart id="mainChart" width="403" height="232" />
<mx:Button label="Fetch" click="populateStaticChart()"/>

<mx:Script>
        <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.collections.XMLListCollection;
                import mx.charts.series.ColumnSeries;
                import mx.charts.CategoryAxis;

public function populateStaticChart():void
{
   var oData:XMLList = null;
   var oXML:XML =
<data>
   <row>
     <Platform>Convergence</Platform>
     <Year>2005</Year>
     <PageConvergenceMSMUnits>3.654</PageConvergenceMSMUnits>
   </row>
   <row>
     <Platform>Convergence</Platform>
     <Year>2006</Year>
     <PageConvergenceMSMUnits>4.3</PageConvergenceMSMUnits>
   </row>
   <row>
     <Platform>Convergence</Platform>
     <Year>2007</Year>
     <PageConvergenceMSMUnits>4.972</PageConvergenceMSMUnits>
   </row>
   <row>
     <Platform>Convergence</Platform>
     <Year>2008</Year>
     <PageConvergenceMSMUnits>16.117</PageConvergenceMSMUnits>
   </row>
   <row>
     <Platform>Convergence</Platform>
     <Year>2009</Year>
     <PageConvergenceMSMUnits>27.248</PageConvergenceMSMUnits>
   </row>
   <row>
     <Platform>Convergence</Platform>
     <Year>2010</Year>
     <PageConvergenceMSMUnits>29.56</PageConvergenceMSMUnits>
   </row> 
</data>;
      oData = oXML.row;
      
      var oXMLCol:XMLListCollection = new XMLListCollection(oData);
      var aYears:Array = [ "2005","2006","2007","2008","2009","2010" ];
      
      // add the category axis to the chart
      var hAxis:CategoryAxis = new CategoryAxis();
      
      // *****  this works *****
      //hAxis.categoryField    = "Year" ;
      //hAxis.dataProvider     = oXMLCol;
      
      // *****  this doesn't *****
      hAxis.categoryField    = null ;
      hAxis.dataProvider     = aYears;
                  
      hAxis.name                  = "Year" ;
      mainChart.horizontalAxis    = hAxis;

      // add a series to the chart and try to use the
XMLListCollection as the DP
      var sa:Array                  = mainChart.series
      var cSeries:ColumnSeries      = new ColumnSeries();
      cSeries.yField                = "PageConvergenceMSMUnits" ;
      cSeries.name                  = "Convergence";
      cSeries.dataProvider          = oXMLCol;
//      cSeries.stackField          = "PageConvergenceMSMUnits";

      sa.push( cSeries );
      mainChart.series = sa;
}

                
]]>
</mx:Script>    
        
</mx:Application>





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to