Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've studied your problem, deeping in initializing ColumnChart component. There is a feature, that all columns from series is placed in separate layer. So, either green columns are on the top or red. No posibility to change parent of one column from series...I'm afraid you have to override the basic behavior of component and place all columns in the same container and sort their depths. I drew an example:</p> <pre><code>&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="900" height="600"&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.charts.series.items.ColumnSeriesItem; import mx.collections.ArrayCollection; [Bindable] public var expenses:ArrayCollection = new ArrayCollection([ {Month:"Jan", Profit:200, Expenses:100, Expenses2:50}, {Month:"Feb", Profit:1000, Expenses:2000, Expenses2:500}, {Month:"Mar", Profit:1100, Expenses:500, Expenses2:100}, {Month:"Apr", Profit:1300, Expenses:900, Expenses2:1000}, {Month:"May", Profit:900, Expenses:1200, Expenses2:1000}, {Month:"June", Profit:1000, Expenses:2000, Expenses2:1500} ]); private var items:Array = []; private function init():void { items = []; for (var i:int=0; i&lt;myChart.series.length; i++) { var series:ColumnSeries = myChart.series[i] as ColumnSeries; for (var j:int=0; j&lt;series.items.length; j++) { if (!items[j]) items[j] = []; var item:ColumnSeriesItem = series.items[j] as ColumnSeriesItem; items[j][i] = item; series.parent.addChild(item.itemRenderer as DisplayObject); } } sort(); } private function sort():void { var h:Number = myChart.height - 50; for (var i:int=0; i&lt;items.length; i++) { var group:Array = items[i]; group.sort(sortFunction); for (var j:int=0; j&lt;group.length; j++) { var item:ColumnSeriesItem = group[j] as ColumnSeriesItem; item.itemRenderer.parent.setChildIndex(item.itemRenderer as DisplayObject, group.length - j - 1); item.min = NaN; if (j &gt; 0) item.min = h - group[j-1].itemRenderer.height; } } } private function sortFunction(item1:ColumnSeriesItem, item2:ColumnSeriesItem):int { var yValue1:int = item1.item[Object(item1.element).yField]; var yValue2:int = item2.item[Object(item2.element).yField]; return (yValue1 &lt; yValue2) ? -1 : (yValue1 &gt; yValue2) ? 1 : 0; } ]]&gt; &lt;/fx:Script&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;/fx:Declarations&gt; &lt;s:BorderContainer width="100%" height="100%" &gt; &lt;s:layout&gt; &lt;s:VerticalLayout horizontalAlign="center"/&gt; &lt;/s:layout&gt; &lt;mx:ColumnChart id="myChart" width="65%" dataProvider="{expenses}" showDataTips="true" type="overlaid" updateComplete="init()" &gt; &lt;mx:horizontalAxis&gt; &lt;mx:CategoryAxis dataProvider="{expenses}" categoryField="Month" /&gt; &lt;/mx:horizontalAxis&gt; &lt;mx:series&gt; &lt;mx:ColumnSeries yField="Profit" displayName="Profit" &gt; &lt;mx:fill&gt; &lt;s:SolidColor color="0x00ff00"/&gt; &lt;/mx:fill&gt; &lt;/mx:ColumnSeries&gt; &lt;mx:ColumnSeries yField="Expenses" displayName="Expenses" &gt; &lt;mx:fill&gt; &lt;s:SolidColor color="0xff0000"/&gt; &lt;/mx:fill&gt; &lt;/mx:ColumnSeries&gt; &lt;mx:ColumnSeries yField="Expenses2" displayName="Expenses2" &gt; &lt;mx:fill&gt; &lt;s:SolidColor color="0xffff00"/&gt; &lt;/mx:fill&gt; &lt;/mx:ColumnSeries&gt; &lt;/mx:series&gt; &lt;/mx:ColumnChart&gt; &lt;mx:Legend dataProvider="{myChart}"/&gt; &lt;mx:DataGrid dataProvider="{expenses}" editable="true"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn dataField="Month" editable="true"/&gt; &lt;mx:DataGridColumn dataField="Profit" editable="true"/&gt; &lt;mx:DataGridColumn dataField="Expenses" editable="true"/&gt; &lt;mx:DataGridColumn dataField="Expenses2" editable="true"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; &lt;/s:BorderContainer&gt; &lt;/s:Application&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload