开发者

breaking up line chart in flex charting

开发者 https://www.devze.com 2022-12-20 04:56 出处:网络
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

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开发者_StackOverflow中文版 that it looks like two diffferent lines on the same chart. Any idea how to proceed with it.

Thanks, PK


First, you can add multiple line series by a criteria in your Array Collection:

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

You can change the width and color of the lines for each series by using the tag. Making each line a different stroke and color.

<?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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号