1 Reply Latest reply on Sep 9, 2008 2:52 PM by Developer504

    Minor emergency: Sorting a chart

    Developer504 Level 1
      I thought I had this 'sorted' out several weeks ago, but today as we go into deployment I find that there was a problem which my test-data didn't reveal.

      I have a simple barchart, and I want it to sort by the field 'hours':

      <mx:BarChart x="{this.width * 0.0125}" y="{this.height * 0.45}" id="TopProjects" height="50%" dataProvider="{xmlListCollTP}" width="50%" showDataTips="True" fontSize="10" dataTipFunction="dtFunc2">
      <mx:CategoryAxis categoryField="@prName" />

      <mx:LinearAxis labelFunction="formatNumber" />

      <mx:BarSeries displayName="Project" xField="@hours" fill="{sc1}" stroke="{s1}">

      The data sort is put into this XMLListCollection, which I thought would make it sort the thing by hours. But there is a problem.

      <mx:XMLListCollection id="xmlListCollTP" source="{tpDs}">
      <mx:SortField id="sortFieldTP" name="@hours" caseInsensitive="true"

      <job prName="Project1" hours="102.50"/>
      <job prName="Project2" hours="78.25"/>
      <job prName="Project3" hours="68.50"/>
      <job prName="Project4" hours="55.50"/>
      <job prName="Project5" hours="41.25"/>

      My problem is that the sort field, @hours, is sorting as if it were a string, so it's sorting 2-5 followed by 1. How can I get it to sort on that field as a number?

      Kind of under the gun here any help would be greatly appreciated.