如何使用jfreecharts生成图表?

时间:2011-11-23 04:56:16

标签: java jasper-reports jfreechart

单击按钮时,我尝试使用JFreeChart生成图表。我复制了下面的完整方法。我的问题是当我尝试生成图表时,我收到一个错误,提到找不到DialFrame的类。

方式

private void btnPreviewActionPerformed(java.awt.event.ActionEvent evt) {
    jPanel1.setSize(pwid, phei);
    try {
        //Map<String, Object> params = new HashMap<String, Object>();
        Map params = new HashMap();
        params.put("year", comyear.getSelectedItem().toString());
        params.put("comcode", comCompCode.getSelectedItem().toString());
        params.put("comname", comCompNam.getSelectedItem().toString());
        params.put("itcode", comItmCode.getSelectedItem().toString());
        params.put("itname", comItmNam.getSelectedItem().toString());
        createExportChartImage();
        JasperReport jasperReport = JasperCompileManager.compileReport("Report/MIS/ExportChart.jrxml");
        Connection conn = (Connection) ClsCon.cont();
        JasperPrint jasperPrint = JasperManager.fillReport(jasperReport, params, conn);
        JasperViewer.setDefaultLookAndFeelDecorated(true);
        JRViewer jrv = new JRViewer(jasperPrint);
        jrv.setPreferredSize(new Dimension(jPanel1.getSize()));
        JScrollPane reportScroll = new JScrollPane(jrv);
        jPanel1.add(reportScroll);
        setBounds(jPanel1.getBounds());
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        jPanel1.add(jrv);
        con.close();

        this.setBounds(0, 0, wid, hei);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e + "Error 281");
    }
}

错误

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jfree/chart/plot/dial/DialFrame
        at net.sf.jasperreports.charts.util.ChartUtil.getChartTheme(ChartUtil.java:152)
        at net.sf.jasperreports.engine.fill.JRFillChart.evaluateChart(JRFillChart.java:1330)
        at net.sf.jasperreports.engine.fill.JRFillChart.evaluateRenderer(JRFillChart.java:1305)
        at net.sf.jasperreports.engine.fill.JRFillChart.evaluate(JRFillChart.java:1294)
        at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
        at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2026)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooter(JRVerticalFiller.java:922)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooters(JRVerticalFiller.java:788)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:298)
        at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:134)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:942)
        at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:841)
        at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
        at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
        at net.sf.jasperreports.engine.JasperManager.fillReport(JasperManager.java:688)
        at SAMPLENOTICE.RepChart1.btnPreviewActionPerformed(RepChart1.java:352)
        at SAMPLENOTICE.RepChart1.access$200(RepChart1.java:35)
        at SAMPLENOTICE.RepChart1$3.actionPerformed(RepChart1.java:123)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
        at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
        at java.awt.Component.processMouseEvent(Component.java:6175)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
        at java.awt.Component.processEvent(Component.java:5940)
        at java.awt.Container.processEvent(Container.java:2105)
        at java.awt.Component.dispatchEventImpl(Component.java:4536)
        at java.awt.Container.dispatchEventImpl(Container.java:2163)
        at java.awt.Component.dispatchEvent(Component.java:4362)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
        at java.awt.Container.dispatchEventImpl(Container.java:2149)
        at java.awt.Window.dispatchEventImpl(Window.java:2478)
        at java.awt.Component.dispatchEvent(Component.java:4362)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: java.lang.ClassNotFoundException: org.jfree.chart.plot.dial.DialFrame
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        ... 44 more

0 个答案:

没有答案