The BarChart can be pretty persnickety about how the data is arranged.  You didn't fully explain exactly what you wanted the chart to look like, so I made some assumptions.  Like I assumed you wanted the axis to say "gold, red, yellow."  The BarChart doesn't seem to like it much when each axis category isn't in its own object.  And as far as I know, you need a category axis for this to even see any values.

Caveat - I never actually work with BarCharts.  So there might be better ways to do this.  But here's one way that works:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
  <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
   
    [Bindable] public var myData:ArrayCollection = new ArrayCollection([
        {
          colors:[
            { color: "green", value: 80 },
            { color: "yellow", value: 20 },
            { color: "red", value: 10 }
          ]
        },
        {
          colors:[
            { color: "green", value: 30 },
            { color: "yellow", value: 5 },
            { color: "red", value: 60 }
          ]
        }
      ]);
    ]]>
  </mx:Script>
  <mx:DataGrid dataProvider="{myData}" width="100%" height="100%">
    <mx:columns>
      <mx:DataGridColumn headerText="Have a Chart">
        <mx:itemRenderer>
          <mx:Component>
            <mx:Canvas>
              <mx:BarChart dataProvider="{ data.colors}" width="100%">
                <mx:verticalAxis>
                  <mx:CategoryAxis categoryField="color"/>
                </mx:verticalAxis>
                <mx:series>
                  <mx:BarSeries yField="color" xField="value"/>
                </mx:series>
              </mx:BarChart>
            </mx:Canvas>
          </mx:Component>
        </mx:itemRenderer>
      </mx:DataGridColumn>
    </mx:columns>
  </mx:DataGrid>
</mx:Application>



On 7/19/06, klumikaze <[EMAIL PROTECTED]> wrote:

I'm having trouble passing data to an itemRenderer (which is a
BarChart). Essentially what I want to do is have a DataGrid with a few
columns and a chart representing three colors (green, yellow nad red)
as BarSeries components. Normally passing data in to itemRenders works
for me this way:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
public var myData:ArrayCollection = new ArrayCollection([{colors:
{green:80, yellow:20, red:0}}]);

]]>
</mx:Script>
<mx:DataGrid dataProvider="{myData}">
<mx:columns>
<mx:DataGridColumn dataField="colors">
<mx:itemRenderer>
<mx:Component>
<mx:BarChart dataProvider="{data.colors}">
<mx:series>
<mx:BarSeries xField="green" />
<mx:BarSeries xField="yellow" />
<mx:BarSeries xField="red" />
</mx:series>
</mx:BarChart>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>




--
Jason __._,_.___

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





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to