Re: [flexcoders] Re: Chart data disappears when printing with a print-specific output format
Well done John!! 2011/10/12 John Fletcher fletch...@gmail.com ** aha I figured it out, the series array is getting mucked up/changed around by the print specific line chart. You have to duplicate it, see http://www.saltwebsites.com/2011/flex-print-specific-chart John 2011/10/11 John Fletcher I followed the advice at http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c80.html to print using a print-specific output format in Flex 4.5, however this causes the data to disappear from my chart! Try the code below - is this a bug or is there a simple solution? One interesting side-effect is that after you print and the data disappears from your chart, you can still hover over the empty chart and get the dataTips pop up! :-) John ?xml version=1.0 encoding=utf-8? s:WindowedApplication xmlns:fx=http://ns.adobe.com/mxml/2009; xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx width=800 height=600 fx:Script ![CDATA[ import mx.charts.LineChart; import mx.printing.FlexPrintJob; import mx.collections.ArrayCollection; [Bindable] public var expensesAC:ArrayCollection = new ArrayCollection( [ { Month: Jan, Profit: 2000, Expenses: 1500, Amount: 450 }, { Month: Feb, Profit: 1000, Expenses: 200, Amount: 600 }, { Month: Mar, Profit: 1500, Expenses: 500, Amount: 300 }, { Month: Apr, Profit: 1800, Expenses: 1200, Amount: 900 }, { Month: May, Profit: 2400, Expenses: 575, Amount: 500 } ]); protected function button1_clickHandler(event:MouseEvent):void { var printJob:FlexPrintJob = new FlexPrintJob(); if (printJob.start()) { var lc:LineChart = new LineChart(); lc.height = mlc.height; lc.width = mlc.width; lc.dataProvider = mlc.dataProvider; lc.series = mlc.series; lc.seriesFilters = mlc.seriesFilters; lc.horizontalAxis = mlc.horizontalAxis; lc.verticalAxis = mlc.verticalAxis; addElement(lc); printJob.addObject(lc); printJob.send(); removeElement(lc); } } ]] /fx:Script s:HGroup mx:LineChart id=mlc dataProvider={expensesAC} showDataTips=true mx:horizontalAxis mx:CategoryAxis categoryField=Month/ /mx:horizontalAxis mx:series mx:LineSeries yField=Profit form=curve displayName=Profit/ mx:LineSeries yField=Expenses form=curve displayName=Expenses/ mx:LineSeries yField=Amount form=curve displayName=Amount/ /mx:series /mx:LineChart s:Button label=print click=button1_clickHandler(event)/ /s:HGroup /s:WindowedApplication
[flexcoders] Re: Chart data disappears when printing with a print-specific output format
aha I figured it out, the series array is getting mucked up/changed around by the print specific line chart. You have to duplicate it, see http://www.saltwebsites.com/2011/flex-print-specific-chart John 2011/10/11 John Fletcher I followed the advice at http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7c80.html to print using a print-specific output format in Flex 4.5, however this causes the data to disappear from my chart! Try the code below - is this a bug or is there a simple solution? One interesting side-effect is that after you print and the data disappears from your chart, you can still hover over the empty chart and get the dataTips pop up! :-) John ?xml version=1.0 encoding=utf-8? s:WindowedApplication xmlns:fx=http://ns.adobe.com/mxml/2009; xmlns:s=library://ns.adobe.com/flex/spark xmlns:mx=library://ns.adobe.com/flex/mx width=800 height=600 fx:Script ![CDATA[ import mx.charts.LineChart; import mx.printing.FlexPrintJob; import mx.collections.ArrayCollection; [Bindable] public var expensesAC:ArrayCollection = new ArrayCollection( [ { Month: Jan, Profit: 2000, Expenses: 1500, Amount: 450 }, { Month: Feb, Profit: 1000, Expenses: 200, Amount: 600 }, { Month: Mar, Profit: 1500, Expenses: 500, Amount: 300 }, { Month: Apr, Profit: 1800, Expenses: 1200, Amount: 900 }, { Month: May, Profit: 2400, Expenses: 575, Amount: 500 } ]); protected function button1_clickHandler(event:MouseEvent):void { var printJob:FlexPrintJob = new FlexPrintJob(); if (printJob.start()) { var lc:LineChart = new LineChart(); lc.height = mlc.height; lc.width = mlc.width; lc.dataProvider = mlc.dataProvider; lc.series = mlc.series; lc.seriesFilters = mlc.seriesFilters; lc.horizontalAxis = mlc.horizontalAxis; lc.verticalAxis = mlc.verticalAxis; addElement(lc); printJob.addObject(lc); printJob.send(); removeElement(lc); } } ]] /fx:Script s:HGroup mx:LineChart id=mlc dataProvider={expensesAC} showDataTips=true mx:horizontalAxis mx:CategoryAxis categoryField=Month/ /mx:horizontalAxis mx:series mx:LineSeries yField=Profit form=curve displayName=Profit/ mx:LineSeries yField=Expenses form=curve displayName=Expenses/ mx:LineSeries yField=Amount form=curve displayName=Amount/ /mx:series /mx:LineChart s:Button label=print click=button1_clickHandler(event)/ /s:HGroup /s:WindowedApplication