Alright, first round at printing....and after about 30 blank pages, I can't figure it out. Just doing an addChild to a sprite with the chart itself works fine. Creating the Bitmap/UI component like you said works fine - but printing it shows up as blank. Here's a real easy example you can use to see what I'm doing: if you uncomment the sprite.addChild(tempUI) and do addChild(myLineChart), it works fine.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application layout="absolute" verticalGap="100"
creationComplete="initApp()"
xmlns:mx="http://www.adobe.com/2006/mxml"
>
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
import mx.collections.ArrayCollection;
import mx.charts.series.LineSeries;
private function initApp():void {
addLineSeries();
}
private function printChart():void {
var myBMD :BitmapData
= new
BitmapData(myLineChart.width,myLineChart.height,true);
myBMD.draw(myLineChart);
var image :Bitmap
= new Bitmap(myBMD);
var tempUI :UIComponent
= new UIComponent();
tempUI.addChild(image);
tempUI.x = 0;
tempUI.y = 0;
tempUI.cacheAsBitmap = true;
var sheet1 :Sprite
= new Sprite();
sheet1.addChild(tempUI);
//To see it print, uncomment this and REMOVE
PrintJobOptions
//sheet1.addChild(myLineChart);
var pj :PrintJob
= new PrintJob();
var pagesToPrint :uint
= 0;
var options:PrintJobOptions = new
PrintJobOptions();
options.printAsBitmap = true;
if(pj.start()) {
sheet1.height = pj.pageHeight / 2;
sheet1.width = pj.pageWidth;
try {
pj.addPage(sheet1,null,options);
pagesToPrint++;
}
catch(e:Error) {
}
if(pagesToPrint > 0) {
pj.send();
}
}
// */
}
private function addLineSeries():void {
var mySeries:Array = new Array();
var newLineSeries:LineSeries = new LineSeries();
newLineSeries.filterData = true;
newLineSeries.interpolateValues = true;
newLineSeries.yField = "amount";
newLineSeries.form = "curve";
mySeries.push(newLineSeries);
myLineChart.series = mySeries;
}
private var __alteredData : ArrayCollection = new
ArrayCollection([{name:1,amount:"100"},
{name:2,amount:"200"},
{name:3,amount:"0"},
{name:4,amount:"50"},
{name:5,amount:"0"},
{name:6,amount:"150"},
{name:7,amount:"200"}]);
]]>
</mx:Script>
<mx:Button x="0" y="0" label="Print" click="printChart()"/>
<mx:LineChart x="0" y="20" id="myLineChart"
dataProvider="{__alteredData}" width="100%" height="100%"
showDataTips="true">
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{__alteredData}"
categoryField="name"/>
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis maximum="200"/>
</mx:verticalAxis>
</mx:LineChart>
</mx:Application>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

