开发者

flex recover space wasted by invisible axis

I want to show multiple series on a chart. But this would result in multiple axis, to avoid this I am trying to make some axis invisible.

Question: When i set the axis renderer's invisible = false, there is a white space that is left behind.

Is there any way to avoid this white space from showing up ?

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

     [Bindable]
      public var DS:ArrayCollection = new ArrayCollection([
        {date:"22-Aug-05", expense:1575.9, tax:41.87, price: 4},
        {date:"23-Aug-05", expense:NaN, tax:NaN,price: 4},
        {date:"24-Aug-05", expense:1507.1, tax:42.77,price:5 },
        {date:"25-Aug-05", expense:1568.8 ,tax:48.06, price:5},
     ]);

     public function dtFunc(hd:HitData):String {
        if(""+hd.item.expense == "NaN")
         return "";
        else 
         return hd.item.expense ;
     }



  ]]></mx:Script>

 <mx:SolidColor id="sc1" color="blue" alpha=".8"/>
 <mx:Stroke id="s1" color="blue" weight="1"/>


  <mx:Panel title="Column开发者_运维技巧 Chart With Multiple Axes">
     <mx:CartesianChart id="myChart" showDataTips="true" dataTipFunction="dtFunc">
        <mx:horizontalAxis>
           <mx:CategoryAxis id="h1" categoryField="date"/>
        </mx:horizontalAxis>

        <mx:horizontalAxisRenderers>
            <mx:AxisRenderer placement="bottom" axis="{h1}"/>
        </mx:horizontalAxisRenderers>

        <mx:verticalAxisRenderers>
            <mx:AxisRenderer placement="left" axis="{v1}"/>
            <mx:AxisRenderer placement="left" axis="{v3}" visible="false"/>
        </mx:verticalAxisRenderers>

        <mx:series>
           <mx:ColumnSeries id="cs1" 
                horizontalAxis="{h1}" 
                dataProvider="{DS}" 
                yField="expense" 
                displayName="EXPENSE-BARCHART"
                filterData="false"
            >
                <mx:verticalAxis>
                   <mx:LinearAxis id="v1" />
                </mx:verticalAxis>           
           </mx:ColumnSeries>           


           <mx:LineSeries id="cs3" horizontalAxis="{h1}" dataProvider="{DS}" yField="price" 
            displayName="Price" form="step"
            >
                <mx:verticalAxis>
                    <mx:LinearAxis id="v3"   />           
                </mx:verticalAxis>

           </mx:LineSeries>
        </mx:series>
     </mx:CartesianChart>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>


try adding attributes showLine="false" showLabels="false" tickPlacement="none" inside axisrenderer.

it works well for me, but I'm not sure if it is already too late for you. Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜