问题描述
<s:Panel title="柱状图实例"> <!--柱状图--><mx:ColumnChart id="mychart" dataProvider="{finance}" x="0" y="0"><mx:horizontalAxis><mx:CategoryAxis dataProvider="{finance}" categoryField="mouth" title="(月份)"/></mx:horizontalAxis><mx:series><mx:ColumnSeries xField="mouth" yField="In" displayName="收入"/><mx:ColumnSeries xField="mouth" yField="out" displayName="支出"/></mx:series></mx:ColumnChart></s:Panel><mx:Legend dataProvider="{mychart}" x="406" y="380"/><fx:Script><![CDATA[import mx.collections.ArrayCollection;import mx.controls.Alert;//记录每月收入支出的数据集[Bindable]public var finance:ArrayCollection=new ArrayCollection([{month:"一月",In:2000,out:1500},{month:"二月",In:1000,out:200},{month:"三月",In:1500,out:200},{month:"四月",In:3500,out:1000},{month:"五月",In:500,out:800},{month:"六月",In:4500,out:600},{month:"七月",In:2500,out:500},{month:"八月",In:1570,out:300},{month:"九月",In:1000,out:450},{month:"十月",In:1500,out:400},{month:"十一月",In:1700,out:2500},{month:"十二月",In:1800,out:1500},]) ]]></fx:Script>
解决方案
<mx:CategoryAxis dataProvider="{finance}" categoryField="mouth" title="(月份)"/> 这一行中的categoryField要跟finance中的字段名称对应,应该为month