Stack the Profit and Expenses fields, in which some of the values are negative. : Column Chart « Chart « Flex






Stack the Profit and Expenses fields, in which some of the values are negative.

Stack the Profit and Expenses fields, in which some of the values are negative.
             

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->


<!-- charts/StackedNegative.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    xmlns:s="library://ns.adobe.com/flex/spark" height="600">
    <fx:Script> 
        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} 
        ]); 
      </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <s:Panel title="Column Chart">
        <s:layout>
            <s:HorizontalLayout />
        </s:layout>
        <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}" />
    </s:Panel>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.PieChart vs ColumnChartPieChart vs ColumnChart
2.ColumnChart DemoColumnChart Demo
3.Waterfall Stacked ColumnChartWaterfall Stacked ColumnChart
4.Create a PieChart control from the selected columns in the ColumnChart control.Create a PieChart control from the selected columns in the ColumnChart control.
5.Column Chart Demo and CategoryAxisColumn Chart Demo and CategoryAxis
6.Combine column chart and pie chartCombine column chart and pie chart
7.Using strokes in ActionScriptUsing strokes in ActionScript
8.You can also represent the range of dates in MXML by using the following syntax:You can also represent the range of dates in MXML by using the following syntax:
9.Creating a custom Legend controlCreating a custom Legend control
10.Add new grid lines as annotation elements to the chart and an image as the background elementAdd new grid lines as annotation elements to the chart and an image as the background element
11.Define the grid lines inside each chart control's definitionDefine the grid lines inside each chart control's definition
12.Turns on grid lines in both directions and applies them to the chart:Turns on grid lines in both directions and applies them to the chart:
13.Define set of filters, and then applies them to various chart elements:Define set of filters, and then applies them to various chart elements:
14.Mixed ChartMixed Chart
15.Multiple Axis ChartMultiple Axis Chart
16.Display two chartsDisplay two charts
17.Define two colors and then uses those colors in the axis renderers and in the strokes and fills for the chart itemsDefine two colors and then uses those colors in the axis renderers and in the strokes and fills for the chart items
18.Make Chart From Drag DropMake Chart From Drag Drop