如何在 Adob​​e Flash Builder 中使用滑块控制柱形图?

发布于 2024-11-09 13:09:05 字数 123 浏览 3 评论 0原文

我在 Adob​​e Flash Builder 中创建了柱形图。

现在我想用滑块控制柱形图。 我想根据滑块的值更改柱形图。

我怎样才能实现这个目标?

任何建议都有帮助。 提前致谢 !

I have created Columnchart in Adobe Flash Builder.

Now I want to control that column chart with Slider.
I want to change the column chart according to value of the slider.

How can I achieve this?

Any suggestions are helpful.
Thanks in Advance !

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

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

发布评论

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

评论(1

情域 2024-11-16 13:09:05

您需要为 更改 事件到您的 Slider 组件。
然后,您更新图表的数据提供程序并将其重新分配给图表。
以下是 Tour de Flex 的修改示例。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"
    horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">

    <mx:Script>
        <![CDATA[

        import mx.collections.ArrayCollection;

        [Bindable]
        private var medalsAC:ArrayCollection = new ArrayCollection( [
            { Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
            { Country: "China", Gold: 32, Silver:17, Bronze: 14 },
            { Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);
        //slider change handler
        private function columnSliderChanged(event:Event):void{
            trace(columnSlider.value);//print slider
            medalsAC.getItemAt(1).Gold = columnSlider.value * 10;//assign slider value to Gold for China (item index 1)
            column.dataProvider = medalsAC;//re-assign data provider
        }
        ]]>
    </mx:Script>

    <mx:Panel title="ColumnChart Control" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="240"
         paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center">

         <mx:ColumnChart id="column" height="100%" color="0x323232"
            showDataTips="true" dataProvider="{medalsAC}">

            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Country"/>
            </mx:horizontalAxis>

            <mx:series>
                <mx:ColumnSeries xField="Country" yField="Gold" displayName="Gold"/>
                <mx:ColumnSeries xField="Country" yField="Silver" displayName="Silver"/>
                <mx:ColumnSeries xField="Country" yField="Bronze" displayName="Bronze"/>
            </mx:series>
        </mx:ColumnChart>

        <mx:Legend dataProvider="{column}" color="0x323232"/>

    </mx:Panel>
    <!-- added a slider here, updates on dragging and has a change event handler -->
    <mx:HSlider id="columnSlider" liveDragging="true" change="columnSliderChanged(event);"/>
</mx:Application>

You need to add a listener for the Change Event to your Slider component.
Then you update the chart's data provider and re-assign it to the chart.
Here's a modified sample from Tour de Flex.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"
    horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">

    <mx:Script>
        <![CDATA[

        import mx.collections.ArrayCollection;

        [Bindable]
        private var medalsAC:ArrayCollection = new ArrayCollection( [
            { Country: "USA", Gold: 35, Silver:39, Bronze: 29 },
            { Country: "China", Gold: 32, Silver:17, Bronze: 14 },
            { Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]);
        //slider change handler
        private function columnSliderChanged(event:Event):void{
            trace(columnSlider.value);//print slider
            medalsAC.getItemAt(1).Gold = columnSlider.value * 10;//assign slider value to Gold for China (item index 1)
            column.dataProvider = medalsAC;//re-assign data provider
        }
        ]]>
    </mx:Script>

    <mx:Panel title="ColumnChart Control" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="240"
         paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center">

         <mx:ColumnChart id="column" height="100%" color="0x323232"
            showDataTips="true" dataProvider="{medalsAC}">

            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="Country"/>
            </mx:horizontalAxis>

            <mx:series>
                <mx:ColumnSeries xField="Country" yField="Gold" displayName="Gold"/>
                <mx:ColumnSeries xField="Country" yField="Silver" displayName="Silver"/>
                <mx:ColumnSeries xField="Country" yField="Bronze" displayName="Bronze"/>
            </mx:series>
        </mx:ColumnChart>

        <mx:Legend dataProvider="{column}" color="0x323232"/>

    </mx:Panel>
    <!-- added a slider here, updates on dragging and has a change event handler -->
    <mx:HSlider id="columnSlider" liveDragging="true" change="columnSliderChanged(event);"/>
</mx:Application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文