2005 IR Help Posted August 27, 2006 Share Posted August 27, 2006 By: ann - ann04 chart displaying 2004-10-18 11:05 Hello... I have a problem displaying a chart from my report. When I run FillReport, the file gets created but the chart image is not there, Please Help! Here is what I have: public static void main(String[] args) throws JRScriptletException{ try{JasperReport jasperReport = (JasperReport)JRLoader.loadObject("myFile.jasper"); parameters.put("Chart",createEmployeeChartImage()); conn = DriverManager.getConnection(url, "123", "123r"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); }//try catch(Exception e){ e.printStackTrace();} } private static java.awt.Image createEmployeeChartImage(){ //public void afterReportInit() throws JRScriptletException{ DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Olga1", new Double(43.2)); dataset.setValue("Olga2", new Double(10.0)); dataset.setValue("C/C++", new Double(17.5)); dataset.setValue("PHP", new Double(32.5)); dataset.setValue("Python", new Double(1.0)); JFreeChart chart = ChartFactory.createPieChart3D( "Pie Chart 3D Demo 1", dataset, true, true, false ); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); //plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart.createBufferedImage(500, 220);} } What is the correct stmt to draw the chart?? chart.createBufferedImage(500, 220) creates the image, then why I cannot see it? Thank you By: ann - ann04 RE: chart displaying 2004-10-18 12:13 Nevermind, Got it solved! By: odc - sameena RE: chart displaying 2004-10-20 02:07 hi ann04 i have the same problem can u tell me how u solved it.my code is just like urs. when i export the report into a pdf a blank pdf page is generated on the browser thks in advance By: ann - ann04 RE: chart displaying 2004-10-21 12:44 Hello, It might be many reasons, but in my case i was looking for a problem in my jsp, when indeed the problem was with the xml file. I called my "chart" image as variable, instead of parameter. When I changed it, the picture showed up in the report. Good luck! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now