Nope. The all charts try to render axes consistently The 'first item' in
a category axis corresponds to zero. A horizontal axis always puts zero
on the left, and a vertical axis always  puts zero (or the lowest value)
on the bottom.  So the first item in the axis goes on the left on the
horizontal, bottom on the vertical.

 

If you wanted to change that, I'd suggest either trying to extend the
Category Axis to reverse the order in which it reports categories, or
write your own.

 

But the easiest way to do it would be to provide a separate dataProvider
to your categoryAxis that has the same values, but sorted in reverse
order. Then make sure you assign an xField to your series (if you don't
provide an xField, it just maps the items to the categories by index,
which would not work. Instead, you want to match the items to the
categories by value, which would place them in the correct spot along
your inverted category axis).

 

Ely.

 

 

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Rick Schmitty
Sent: Thursday, May 31, 2007 10:21 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] BarChart - Reversing draw order?

 

I don't know if thats the correct term or not, but I'm trying to
change the behavior of the BarChart to match ColumnChart (in my mind
at least)

In the example below (modified from livedocs) theres a Column and Bar
chart side by side with a datagrid bound to the same array collection
at the bottom. When you sort the datagrid by Gold Medals, highest to
lowest, the Column chart puts the tallest block first and shortest
last. The BarChart however places the largest bar at the bottom and
the smallest at the top. I'd like to have the largest result at the
top of the BarChart.

Is there a simple attribute that I'm not seeing or will it involve
changing around how the BarChart draws itself to get it to read 'Top
to Bottom' like the ColumnChart does 'Left to Right'

Example code, sort by medals:

<?xml version="1.0"?>
<!-- Simple example to demonstrate the ColumnChart and BarChart
controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable]
private var medalsAC:ArrayCollection = new ArrayCollection( [
{ Country: "USA", Gold: 45, Silver:19, Bronze: 29 },
{ Country: "China", Gold: 32, Silver:27, Bronze: 44 },
{ Country: "Russia", Gold: 27, Silver:37, Bronze: 18 } ]);

]]>
</mx:Script>

<mx:Panel title="ColumnChart and BarChart Controls Example"
height="100%" width="100%" layout="horizontal">

<mx:ColumnChart id="column" height="100%" width="45%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{medalsAC}">

<mx:horizontalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:horizontalAxis>

<mx:series>
<mx:ColumnSeries xField="Country" yField="Gold"
displayName="Gold"/>
<mx:ColumnSeries xField="Country" yField="Silver"
displayName="Silver"/>
<mx:ColumnSeries xField="Country" yField="Bronze"
displayName="Bronze"/>
</mx:series>
</mx:ColumnChart>

<mx:Legend dataProvider="{column}"/>

<mx:BarChart id="bar" height="100%" width="45%"
paddingLeft="5" paddingRight="5"
showDataTips="true" dataProvider="{medalsAC}">

<mx:verticalAxis>
<mx:CategoryAxis categoryField="Country"/>
</mx:verticalAxis>

<mx:series>
<mx:BarSeries yField="Country" xField="Gold"
displayName="Gold"/>
<mx:BarSeries yField="Country" xField="Silver"
displayName="Silver"/>
<mx:BarSeries yField="Country" xField="Bronze"
displayName="Bronze"/>
</mx:series>
</mx:BarChart>

<mx:Legend dataProvider="{bar}"/>

</mx:Panel>
<mx:Panel title="Raw Data">
<mx:DataGrid dataProvider="{medalsAC}"/>
</mx:Panel>
</mx:Application>

 

<<image001.jpg>>

<<image002.jpg>>

Reply via email to