Flex bug?? Get messed up stacked ColumnChart with type="100%"

Posted by Nir on Stack Overflow See other posts from Stack Overflow or by Nir
Published on 2011-06-14T16:06:44Z Indexed on 2012/04/11 5:29 UTC
Read the original article Hit count: 230

Filed under:
|
|

I am trying to do a stacked Column chart with type="100%" and a mixture of positive and negative values. When all the values are positive, is functions well, but when negative numbers come to the game, it looks totally messed up.

When I also look at Adobe documentation (look here), I see the following code for stacked column chart involving negative numbers:

<?xml version="1.0"?>
<!-- charts/StackedNegative.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script><![CDATA[
        import mx.collections.ArrayCollection;
        [Bindable]
        public var expenses:ArrayCollection = new ArrayCollection([
            {Month:"Jan", Profit:-2000, Expenses:-1500},
            {Month:"Feb", Profit:1000, Expenses:-200},
            {Month:"Mar", Profit:1500, Expenses:-500}
        ]);
    ]]></mx:Script>
    <mx:Panel title="Column Chart">
        <mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
            <mx:horizontalAxis>
                <mx:CategoryAxis 
                    dataProvider="{expenses}" 
                    categoryField="Month"
                    />
            </mx:horizontalAxis>
            <mx:series>
                <mx:ColumnSet type="stacked" allowNegativeForStacked="true">
                    <mx:series>
                        <mx:ColumnSeries 
                            xField="Month" 
                            yField="Profit" 
                            displayName="Profit"
                            />
                        <mx:ColumnSeries 
                            xField="Month" 
                            yField="Expenses" 
                            displayName="Expenses"
                            />
                    </mx:series>
                </mx:ColumnSet>           
            </mx:series>
        </mx:ColumnChart>
        <mx:Legend dataProvider="{myChart}"/>
    </mx:Panel>
</mx:Application>

It works fine.

But try to change:

<mx:ColumnSet type="stacked" allowNegativeForStacked="true">

to:

<mx:ColumnSet type="100%" allowNegativeForStacked="true">

and you'll see that it doesn't on January data, where both values are negative, the chart shows as if they are positive, and on the other two where one value is positive and the other is negative, it shows only the positive part as 100%...

Isn't it a Flex Bug? I have my own case with such data and it behaves wrong the same way. I'd expect that if it has 800 stacked on -200, it will show 80% up and 20% down, totalling 100%.

BTW: Using Flex 4, though these are all mx components.

Thanks a lot and regards from Berlin, Germany, Nir.

© Stack Overflow or respective owner

Related posts about flex

Related posts about flex4