Select to view content in your preferred language

add new InfoSymbol with a piechart

729
1
09-19-2010 12:55 AM
yanli
by
Emerging Contributor
i would like put a piechart into InfoSymbol.

   <esri:InfoSymbol id="infoSymbol1">
        <esri:infoRenderer>
            <mx:Component>
                <mx:VBox >
                    <mx:Label  text="{data.getItemAt(0).myphone}"/>
                   
                   <mx:PieChart id="pieChart" dataProvider="{data}" width="60" height="60">
                                    <mx:series>
                                        <mx:PieSeries field="VALUE" nameField="AGE" labelPosition="inside" >
                                      
                                        </mx:PieSeries>
                                    </mx:series>
                                </mx:PieChart>
                  
                </mx:VBox>
            </mx:Component>
        </esri:infoRenderer>
    </esri:InfoSymbol>


public function  addsymbol():void{
   var myGraphic:Graphic=new Graphic(new MapPoint(100,50));
   myGraphic.symbol=infoSymbol1;
             
   var attribs:ArrayCollection=new ArrayCollection([{myphone: "123",VALUE:23,AGE:old},{myphone: "2345",VALUE:78,AGE:new} ]);
      myGraphic.attributes=attribs;
        myGraphicsLayer.add(myGraphic);
                       
                   
                 
     }


when difinite the myGraphic.attributes like this is ok

var attribs:Object = {myphone: "123"}                    
   myGraphic.attributes=attribs;

can   the   "myGraphic.attributes "  be  "ArrayCollection "?

how do i give the date source to piechart in symbol? any other method
Tags (2)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus
Yan,

   You have to try and understand what you are specifying when you add your attributes.

This code works, because number 1 it knows that 'New' and 'Old' variable types are string where what you had would have just produced an error. This ArrayCollection that you are creating is just a collection of objects so it works as attributes for the graphic.

private function addsymbol():void{
                var myGraphic:Graphic=new Graphic(new MapPoint(100,50));
                myGraphic.symbol=infoSymbol;
                
                var attribs:ArrayCollection=new ArrayCollection([{myphone: "123",AGE: "New", VALUE: 23},{myphone: "2345",AGE: "Old", VALUE: 78}]);
                myGraphic.attributes=attribs;
                myGraphicsLayer.add(myGraphic);    
            }
0 Kudos