Flex 中的折线图线段

发布于 2024-08-26 00:25:55 字数 1368 浏览 4 评论 0原文

我正在 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>

我希望这个“利润”系列是蓝色的(就像目前的那样),但我希望该线的第一段(一月、二月)为黄色,另一段(三月、四月、六月)为红色。

我知道我可以在现有的基础上使用适当的颜色为这些部分绘制额外的系列,但我想知道在 Flex 中是否有更优雅的方法来做到这一点?

谢谢你的回答。

I'm doing some line charts in my Flex application, and I need to draw segments of those line chart in different color. Does anyone have an idea how this could be achieved? For instance, if I have a code like this (actually, I have given this trivial example for simplicity (the problem is the same)):

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

I would like this "Profit" series to be blue (as it currently is), but I would like first segment of the line (Jan, Feb) to be, let's say yellow, and another segment, let's say (Mar, Apr, Jun) to be red.

I know I could draw additional series for these segments with proper coloring on top of existing one, but I was wondering is there a more elegant way of doing this in Flex?

Thanks for you answers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心荒芜 2024-09-02 00:25:55

也许,您可以创建自己的自定义折线图系列类。这是 Ely Greenfield 的带有源代码的演示,其中实现了自定义饼图系列。请参阅 SizedPieSeries.as 文件。有一个 radiusField 属性,它是一个自定义属性。我想你也可以对“颜色”做同样的事情。

Probably, you can create your own custom line chart series class. This is a demo with sources by Ely Greenfield where custom PieChart series are implemented. See SizedPieSeries.as file. There is a radiusField property which is a custom one. I guess you can do the same with the 'color'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文