1 Reply Latest reply on Mar 13, 2008 10:22 PM by rohitmarathe

    chart to image

      is there a way to convert chart to image, i am using php in server side.
        • 1. Re: chart to image
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
          import mx.collections.ArrayCollection;
          import mx.core.UIComponent;

          private function getBitmapData( target : UIComponent ) : BitmapData
          var bd : BitmapData = new BitmapData( target.width, target.height );
          var m : Matrix = new Matrix();
          bd.draw( target, m );
          img1.source = new Bitmap(bd);
          return bd;
          private var arrSalesData:ArrayCollection = new ArrayCollection([
          {Year:"2000", Sales:200000,Profit:20000},
          {Year:"2004", Sales:10000000,Profit:4000000},
          {Year:"2007", Sales:20000000,Profit:7500000}
          <mx:Panel x="41" y="20" width="674" height="356" layout="absolute" title="Sales Vs Profit">
          <mx:BarChart x="0" y="0" id="BarChartSales" width="100%" height="281" dataProvider="{arrSalesData}" showDataTips="true">
          <mx:CategoryAxis categoryField="Year"/>
          <mx:BarSeries displayName="Sales" xField="Sales" yField="Year" />
          <mx:BarSeries displayName="Profit" xField="Profit" yField="Year" />
          <mx:Legend dataProvider="{BarChartSales}" x="0" y="280" height="36"/>
          <mx:Button x="543" y="284" label="Save Chart" click="getBitmapData(BarChartSales)"/>
          <mx:Image id='img1' x="41" y="395" width="674" height="303"/>