Flex中的LineChart段

时间:2010-03-19 13:35:10

标签: flex charts linechart

我在Flex应用程序中做了一些折线图,我需要以不同的颜色绘制这些折线图的片段。有谁知道如何实现这一目标?例如,如果我有这样的代码(实际上,我为了简单起见给出了这个简单的例子(问题是相同的)):

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        <![CDATA[
        import mx.collections.ArrayCollection;
        [Bindable]
        private var profit:ArrayCollection = new ArrayCollection( [
            { Month: "Jan", Profit: 2000 },
            { Month: "Feb", Profit: 1000 },
            { Month: "Mar", Profit: 1500 },
            { Month: "Apr", Profit: 1800 },
            { Month: "May", Profit: 2400 },
            { Month: "Jun", Profit: 3500 } 
            ]);
        ]]>
    </mx:Script>
    <mx:Stroke id = "s1" color="blue" weight="2"/>
        <mx:LineChart id="linechart" dataProvider="{profit}">
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Month"/>
            </mx:horizontalAxis>
            <mx:series>
                <mx:LineSeries yField="Profit" form="curve" displayName="Profit" lineStroke="{s1}"/>
            </mx:series>
        </mx:LineChart>
</mx:Application>

我希望这个“Profit”系列是蓝色的(就像现在一样),但是我想要第一段(Jan,Feb),让我们说黄色,另一段,让我们说(Mar) ,4月,6月)是红色的。

我知道我可以为这些片段绘制额外的系列,并在现有片段之上加上适当的颜色,但我想知道在Flex中有更优雅的方法吗?

谢谢你的答案。

1 个答案:

答案 0 :(得分:2)

您可以创建自己的自定义折线图系列类。这是Ely Greenfield的demo with sources,其中实现了自定义的PieChart系列。请参见SizedPieSeries.as文件。 radiusField属性是自定义属性。我想你可以用'颜色'来做同样的事情。