动态弯曲verticalaxisrenderers [英] Dynamic Flex verticalaxisrenderers

查看:117
本文介绍了动态弯曲verticalaxisrenderers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了使用纯AS3 Flex中应用于LineChart。我现在需要将其转换为动态多轴的图表。我用动态的意思是,我可以通过编程方式从verticalaxisrenderer阵列在运行时添加或删除axisrenderers。看来我可以在运行时通过简单地这样做删除axisrenderers:

I've created a linechart in flex using pure as3. I need now to convert it to a dynamic multi axis chart. What I mean by dynamic, is that I can programmatically add or remove axisrenderers from the verticalaxisrenderer array at runtime. It seems i can remove axisrenderers at runtime by simply doing this:

verticalAxisRenderers = verticalAxisRenderers.splice(指数,1);

verticalAxisRenderers = verticalAxisRenderers.splice(index,1);

然而,增加axisrenderers不工作。我做这么:

However, ADDING axisrenderers is not working. I am doing it by so:

verticalAxisRenderers.push(AR2); verticalAxisRenderers = verticalAxisRenderers;

verticalAxisRenderers.push(ar2); verticalAxisRenderers = verticalAxisRenderers;

我在哪里去了?请帮帮忙!

Where am I going wrong? Please help!

谢谢, 音

推荐答案

的误解是,你用verticalAxisRenderers而不是使用系列标签。该渲染器阵列存储该轴的实际渲染,如果你想改变它独立的数组。实际的轴对象存储在您用来显示数据系列。

The misconception is that you use verticalAxisRenderers instead of using the series tag. The renderers arrays are separate arrays that store the actual rendering of the Axis if you want to change it. The actual axis objects are stored in the series you use to show the data.

下面是一个例子:

   <?xml version="1.0"?>
        <!-- charts/MultipleAxes.mxml -->
        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
          <mx:Script><![CDATA[
             import mx.collections.ArrayCollection;

             [Bindable]
              public var SMITH:ArrayCollection = new ArrayCollection([
                {date:"22-Aug-05", close:41.87},
                {date:"23-Aug-05", close:45.74},
                {date:"24-Aug-05", close:42.77},
                {date:"25-Aug-05", close:48.06},
             ]);

             [Bindable]
              public var DECKER:ArrayCollection = new ArrayCollection([
                {date:"22-Aug-05", close:157.59},
                {date:"23-Aug-05", close:160.3},
                {date:"24-Aug-05", close:150.71},
                {date:"25-Aug-05", close:156.88},
             ]);

          ]]></mx:Script>

          <mx:Panel title="Column Chart With Multiple Series">
             <mx:ColumnChart id="myChart"
                dataProvider="{SMITH}"
                showDataTips="true">

                <mx:horizontalAxis>
                   <mx:CategoryAxis 
                        dataProvider="{SMITH}" 
                        categoryField="date"/>
                </mx:horizontalAxis>

                <mx:verticalAxisRenderers>
                    <mx:AxisRenderer placement="left" axis="{v1}"/>
                    <mx:AxisRenderer placement="right" axis="{v2}"/>
                </mx:verticalAxisRenderers>

                <mx:series>
                   <mx:ColumnSeries id="cs1"
                        dataProvider="{SMITH}"
                        xField="date"
                        yField="close"
                        displayName="SMITH">
                        <mx:verticalAxis>
                           <mx:LinearAxis id="v1" minimum="40" maximum="50"/>
                        </mx:verticalAxis>
                    </mx:ColumnSeries>
                    <mx:LineSeries id="cs2"
                            dataProvider="{DECKER}"
                            xField="date"
                            yField="close"
                            displayName="DECKER">
                        <mx:verticalAxis>
                            <mx:LinearAxis id="v2" minimum="150" maximum="170"/>
                        </mx:verticalAxis>
                     </mx:LineSeries>
                </mx:series>
             </mx:ColumnChart>
          </mx:Panel>
        </mx:Application>

您可以阅读更多关于这在 HTTP:/ /livedocs.adobe.com/flex/3/html/help.html?content=charts_types_12.html 。警告:不要使用secondAxisRenderer,因为这是德precated

You can read more about this at http://livedocs.adobe.com/flex/3/html/help.html?content=charts_types_12.html. Warning: don't use secondAxisRenderer because this is deprecated.

这篇关于动态弯曲verticalaxisrenderers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆