Select to view content in your preferred language

Help: Drawing bar or pie charts on the map from feature layer!

4291
10
Jump to solution
02-09-2012 04:29 AM
HannesRömer
Occasional Contributor
Hallo,

I am very new to the ArcGIS API for Flex. I am working with FlashBuilder to develop my web-map application. I try to draw pie charts or bar charts from two attribute fields in my feature layer, to illustrate parking occupancy. In the code gallery, I found the example from EEA, so it should be possible.

http://www.eea.europa.eu/themes/water/interactive/soe-rl

However, till now, i didn't find a way how to do this. In the references i only find a way to draw chars in a popup.

(I already had the problem with the conversion of my msx to a msd. Here the applied chart symbology for the shape file involved was not supported for this conversion process. Thus, I thought there is a way to re-edit the feature layers within the Flex API.)


Thank you for your help!
Tags (2)
0 Kudos
10 Replies
RobertScheitlin__GISP
MVP Emeritus
Hannes,

  I'm not real sure on the normalizing the height... I understand what you are wanting I think but right now that might be beyond what I have time to commit to this thread.

As far as your data actually being a polygon and not a point this should take care of that:

Update for the StackedBarSymbol.as

        override public function draw(sprite:Sprite, geometry:Geometry, attributes:Object, map:Map):void
        {
            const width2:Number = m_width / 2.0;
            const height2:Number = m_height / 2.0;
            
            const sx:Number = (m_centerX.valueOf())? 0 - width2 : 0;
            const sy:Number = (m_centerY.valueOf())? 0 - height2 : 0;
            
            const osx:Number = sx - m_offsetX;
            const osy:Number = sy - m_offsetY;
            
            var mapPoint:MapPoint
            if (geometry is MapPoint){
                mapPoint = MapPoint(geometry) as MapPoint;
            }else if (geometry is Polygon){
                mapPoint = Polygon(geometry).extent.center;
            }
            
            sprite.x = toScreenX(map, mapPoint.x);
            sprite.y = toScreenY(map, mapPoint.y);
            sprite.width = m_width;
            sprite.height = m_height;
            sprite.alpha = m_alpha;
            var field1Val:Number = attributes[m_field1] as Number;
            var field2Val:Number = attributes[m_field2] as Number;
            var cTotal:Number = field1Val + field2Val;
            
            var field1ValHgt:Number = (field1Val / cTotal) * m_height;
            var field2ValHgt:Number = (field2Val / cTotal) * m_height
            
            sprite.graphics.beginFill(m_color1, m_alpha);
            sprite.graphics.drawRect(osx , osy, m_width, field1ValHgt);
            sprite.graphics.endFill();
            sprite.graphics.beginFill(m_color2, m_alpha);
            sprite.graphics.drawRect(osx, osy + field1ValHgt, m_width, field2ValHgt);
            sprite.graphics.endFill();
        }
    }
0 Kudos