2010-07-13 24 views
0

如何在不存在更多数据的情况下在LineChart上切断数据?例如,如果我显示的是2010年的公司收入图表,则该图表应该只显示至今年七月(8月份和未显示数据的前瞻期)。这会使折线图中的线断裂并在大约一年中途消失。Flex:为未知的未来数据在LineChart上扩展x轴

回答

0

您需要在dataProvider数组中包含月份,但将其值设置为“”而不是1000。下面的代码显示了如果你运行它,这个工作:

<?xml version="1.0"?> 
<!-- charts/BasicLine.mxml --> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> 
    <mx:Script><![CDATA[ 
    import mx.collections.ArrayCollection; 
    [Bindable] 
    public var expenses:ArrayCollection = new ArrayCollection([ 
     {Month:"Jan", Profit:2000}, 
     {Month:"Feb", Profit:1000}, 
     {Month:"Mar", Profit:""} 
    ]); 
    ]]></mx:Script> 
    <mx:Panel title="Line Chart"> 
    <mx:LineChart id="myChart" 
     dataProvider="{expenses}" 
     showDataTips="true" 
    > 
     <mx:horizontalAxis> 
      <mx:CategoryAxis 
       dataProvider="{expenses}" 
       categoryField="Month" 
      /> 
     </mx:horizontalAxis> 
     <mx:series> 
      <mx:LineSeries 
       yField="Profit" 
       displayName="Profit" 
      />   
     </mx:series> 
    </mx:LineChart> 
    <mx:Legend dataProvider="{myChart}"/> 
    </mx:Panel> 
</mx:Application>