1

I am wondering how will i proceed with the following requirement. I need to create a line chart of business data of the last 8 quarters. It is easy, but the requirement is that, there should not be a connection between last year's Q4 and this years Q1. In effect, using the same array collection i need to split the line chart so that it looks like two diffferent lines on the same chart. Any idea how to proceed with it.

Thanks, PK

4

1 回答 1

2

首先,您可以通过 Array Collection 中的条件添加多行系列:

<mx:series>
           <mx:LineSeries 
                yField="Profit" 
                displayName="Profit"
           />
           <mx:LineSeries 
                yField="Expenses" 
                displayName="Expenses"
           />
        </mx:series>

您可以使用标签更改每个系列的线条的宽度和颜色。使每条线具有不同的笔触和颜色。

<?xml version="1.0"?>
<!-- charts/BasicLineStroke.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, Expenses:1500, Amount:450},
        {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
        {Month:"Mar", Profit:1500, Expenses:500, Amount:300}
     ]);
  ]]></mx:Script>
  <mx:Panel title="Line Chart With Strokes">
     <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:lineStroke>
                <mx:Stroke 
                    color="0x0099FF" 
                    weight="20" 
                    alpha=".2"
                />
            </mx:lineStroke>                
           </mx:LineSeries>
           <mx:LineSeries 
            yField="Expenses" 
            displayName="Expenses"
           >
            <mx:lineStroke>
                <mx:Stroke 
                    color="0x0044EB" 
                    weight="20" 
                    alpha=".8"
                />
            </mx:lineStroke>                
           </mx:LineSeries>
        </mx:series>
     </mx:LineChart>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>
于 2010-02-11T20:24:42.633 回答