views:

38

answers:

1

Hello Everyone,

How do you display data on a LineChart that cuts off where there is no more data? For example, if I am showing a chart of company revenue for 2010, the chart should only show up to July now (with August and forward on showing no data). This would make the line in the line chart break and dissappear off at about midway through the year.

Thanks for any input!

  • Joseph
A: 

Hi

You would need to include the months in the dataProvider array, but set their values to "" instead of 1000 for example. The code below shows this working if you run it:

<?xml version="1.0"?>
<!-- charts/BasicLine.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
  <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>
Brian Bishop