Hi,
Consider the following code snippet to generate a Flash (*.swf) file.
Chart chart = new Chart(); chart.getData().setSeries(2); chart.getData().setPoints(5); chart.setGallery(Gallery.LINES); chart.setWidth(500); chart.setHeight(200); chart.setRenderFormat("Flash"); //$NON-NLS-1$ chart.setOutputWriter(new FlashWriter()); OutputStream os = new FileOutputStream(C:\\charts\\chart.swf"); //$NON-NLS-1$ Writer imgMap = new FileWriter("C:\\charts\\imgMap.txt"); //$NON-NLS-1$ Writer htmlTag = new FileWriter("C:\\charts\\htmlTag.txt"); //$NON-NLS-1$ chart.renderToStream(os, imgMap, htmlTag); htmlTag.close(); imgMap.close(); os.close();
--------------------------------------------------------------
There is indeed a "chart.swf" file generated in that directory. I've attached it for reference. The problem is the SWF file is corrupt or invalid, and cannot be opened with a web browser.
I understand the three-argument version of renderToStream() is generating Flash bitstream data. Does this bitstream need more encoding before it is a valid SWF file? If so, how? I figured I could generate a SWF file easily, but apparently not. Any help greatly appreciated.