2012-05-11 2 views
0

グラフに関連する問題が1つあります。グラフ(ColumnChart、BarChart、LineChart、AreaChartなど) - スクロールバーなしの画像として保存

私はそれにスクロールバーが付いた1000+列の縦棒グラフを持っています。今は私のDisktopやスクロールなしの任意の場所にImageとして保存したい。

ScrollableAxisRendererクラスは、私は以下のことを見つけてくださいリンクのいずれかからダウンロードした: - http://www.connectedpixel.com/blog/scrollingcharts

サンプル列チャート例: - 事前に

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       creationComplete="init();" xmlns:charts="com.connectedpixel.charts.*"> 
    <fx:Declarations> 
     <fx:XML xmlns="" id="myData"> 
      <items> 
       <item year="1960" rain="92" /> 
       <item year="1961" rain="192" /> 
       <item year="1962" rain="32" /> 
       <item year="1963" rain="52" /> 
       <item year="1964" rain="112" /> 
       <item year="1965" rain="52" /> 
       <item year="1966" rain="88" /> 
       <item year="1967" rain="52" /> 
       <item year="1968" rain="66" /> 
       <item year="1969" rain="39" /> 
       <item year="1970" rain="192" /> 
       <item year="1971" rain="182" /> 
       <item year="1972" rain="177" /> 
       <item year="1973" rain="179" /> 
       <item year="1974" rain="198" /> 
       <item year="1975" rain="207" /> 
       <item year="1976" rain="388" /> 
       <item year="1977" rain="372" /> 
       <item year="1978" rain="352" /> 
      </items> 
     </fx:XML> 

     <s:XMLListCollection id="rainData" source="{myData.children()}" /> 

    </fx:Declarations> 
    <fx:Script> 
     <![CDATA[ 
      import mx.graphics.ImageSnapshot; 
      import mx.graphics.codec.PNGEncoder; 

      protected function initCreationComp():void 
      { 
       var image:ImageSnapshot = ImageSnapshot.captureImage(myChart,300,new PNGEncoder(),true); 
       var file:FileReference = new FileReference(); 
       var chartName:String = "myChart"+count+".png"; 
       file.save(image.data, chartName); 
      } 

     ]]> 
    </fx:Script> 

    <mx:VBox width="100%" height="100%" x="50" y="50"> 
     <s:Button label="Download Image" click="initCreationComp()"/> 

     <mx:ColumnChart id="myChart" name="myChart" 
         width="80%" height="80%" 
         dataProvider="{myData.children()}" 
         showDataTips="true" maxColumnWidth="35"> 
      <mx:horizontalAxis> 
       <mx:CategoryAxis id="yearAxis" categoryField="@year" /> 
      </mx:horizontalAxis> 

      <mx:series> 
       <mx:ColumnSeries xField="@year" yField="@rain" displayName="Rain" /> 
      </mx:series> 

      <mx:horizontalAxisRenderers> 
       <charts:ScrollableAxisRenderer id="scrollAxisRenderer" axis="{yearAxis}" tickPlacement="none" 
               placement="bottom" labelGap="3" maxVisibleColumns="4"/> 
      </mx:horizontalAxisRenderers> 

     </mx:ColumnChart> 
    </mx:VBox> 
</s:Application> 

おかげで....

答えて

0

グラフの代わりにスクロールバーが表示されるコンテナ内にグラフを配置します。

<mx:VBox width="100%" height="100%" x="50" y="50"> 
    <s:Button label="Download Image" click="initCreationComp()"/> 
    <mx:VBox width="80%" height="80%" 
      minWidth="100" minHeight="100"> 
     <mx:ColumnChart id="myChart" name="myChart" 
         dataProvider="{myData.children()}" 
         showDataTips="true" maxColumnWidth="35"> 
     <!-- etc --> 
     </mx:ColumnChart> 
    </mx:VBox> 
</mx:VBox> 
+0

私はこれまでに提案したことを試しましたが、それが良いアイデアか良いのか分かりません。私はユーザーの要求に表示される複数のグラフを持っています。上記のケースでは、全体のコードは評判が良いと書かれています。 私は以下を試してみましたが、問題を解決できませんでした: - ObjectUtil.clone()、ObjectUtil.copy グラフの複製またはコピーを作成し、dataProviderを変更する方法はありますか?私は自分のチャートに動的に作成している複数のColumnSeriesを持っていますか? –

+0

実行時に実行している場合は、デスクトップ上に空の画像を保存した結果としてチャートをイメージにすぐに変換することはできません。 –

+0

実際、私はほとんど何かを理解しました。複数のチャートが必要な場合は、純粋なActionScriptでコードを書き直して、チャートをdinamically追加するか、Repeaterを使用するか、レンダラーでList-basedを使用します。 ObjectUtilのクローンとコピーを絶対に使用しないでください。 – moropus

関連する問題