Flex BubbleChart - 使气泡大小相对于图表大小?

发布于 2024-10-11 16:57:01 字数 1380 浏览 3 评论 0原文

我想知道是否有任何方法可以在图表大小调整大小时使气泡大小缩放或调整大小。如果气泡设置为特定的像素大小,则看起来好像大小已设置,仅此而已。因此,如果您的图表较大,则气泡的大小为 X,如果图表较小,则气泡的大小仍为 X。

这是一个示例应用程序,可向您展示我的意思。任何帮助或想法将不胜感激?

谢谢!

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            [Bindable]
            private var s1:ArrayCollection = new ArrayCollection( [
                {"x": 20, "y": 10, "r":10 },
                {"x": 40, "y": 5, "r":20 } ,
                {"x": 60, "y": 0, "r":30 }]);
    ]]>
    </mx:Script>

    <!-- Define custom color and line style for the bubbles. -->
    <mx:SolidColor id="sc1" color="red" alpha=".7"/>
    <mx:Stroke id="stroke1" color="red" weight="2"/>

    <mx:BubbleChart id="myChart" showDataTips="true" height="100%" width="100%"> 
        <mx:series>
            <mx:BubbleSeries 
                dataProvider="{s1}" 
                displayName="series1" 
                xField="x" 
                yField="y" 
                radiusField="r"
                selectable="true"
                fill="{sc1}"
                stroke="{stroke1}"
            />
        </mx:series>   
    </mx:BubbleChart>

</mx:Application>

I'm wondering if there is any way to make the bubble sizes scale or resize when the size of the chart resizes. If the bubbles are set to a specific pixel size, it seems as though the size is set and that's it. So, if your chart is large, the bubble is size X and if the chart is small the bubble is still size X.

Here's a sample app to show you what I mean. Any help or ideas would be appreciated?

Thanks!

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            [Bindable]
            private var s1:ArrayCollection = new ArrayCollection( [
                {"x": 20, "y": 10, "r":10 },
                {"x": 40, "y": 5, "r":20 } ,
                {"x": 60, "y": 0, "r":30 }]);
    ]]>
    </mx:Script>

    <!-- Define custom color and line style for the bubbles. -->
    <mx:SolidColor id="sc1" color="red" alpha=".7"/>
    <mx:Stroke id="stroke1" color="red" weight="2"/>

    <mx:BubbleChart id="myChart" showDataTips="true" height="100%" width="100%"> 
        <mx:series>
            <mx:BubbleSeries 
                dataProvider="{s1}" 
                displayName="series1" 
                xField="x" 
                yField="y" 
                radiusField="r"
                selectable="true"
                fill="{sc1}"
                stroke="{stroke1}"
            />
        </mx:series>   
    </mx:BubbleChart>

</mx:Application>

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

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

发布评论

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

评论(1

独自←快乐 2024-10-18 16:57:01

您可以做的是,向您的应用程序添加一个调整大小事件。

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" resize="handleMainWindowResize()">

在程序的脚本部分中声明函数,并在该函数中更改 BubbleSeries 的属性:

<mx:Script>
        <![CDATA[
public function handleMainWindowResize():void
{
  //change values of s1 according to the percentage increase (this is important)
            for each(series in myChart.series)
            {
                var bubbleSeries:BubbleSeries= series as BubbleSeries;
                bubbleSeries.dataProvider =s1;//Resetting the data provider with the changed values

            }
}
    ]]>

</mx:Script>

或者您始终可以使用缩放变换。
但以上是正确的做法。

What you can do is , add a resize event to your application.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" resize="handleMainWindowResize()">

In script part of the programme declare the function and in that function change the properties of the BubbleSeries:

<mx:Script>
        <![CDATA[
public function handleMainWindowResize():void
{
  //change values of s1 according to the percentage increase (this is important)
            for each(series in myChart.series)
            {
                var bubbleSeries:BubbleSeries= series as BubbleSeries;
                bubbleSeries.dataProvider =s1;//Resetting the data provider with the changed values

            }
}
    ]]>

</mx:Script>

Or you can always use scaling transformations.
But the above is the right way to go through it.

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