如何显示饼图使用我的数据库中的数据

时间:2011-07-02 15:37:37

标签: java jsf primefaces jfreechart

我想生成一个饼图,但图像总是空的这是我的代码(实际上我想在我的页面test.xhtml上显示它但我不能这样,我试图将它显示为图像):< / p>

public void PieChart() throws SQLException, ClassNotFoundException
 {

  String query = "SELECT id, pname from issuestatus";
  JDBCPieDataset dataset = new JDBCPieDataset("jdbc:mysql://localhost:3306/jiradb", "com.mysql.jdbc.Driver","root", "root");
   dataset.executeQuery(query);
 JFreeChart chart = ChartFactory.createPieChart("Pie Chart ",dataset, true, true, false);

 try {
 final ChartRenderingInfo info = new 
  ChartRenderingInfo(new StandardEntityCollection());

  final File file1 = new File("C:/Documents and Settings/piechart.png");
  ChartUtilities.saveChartAsPNG( file1, chart, 600, 400, info);
  } catch (Exception e) {
  e.printStackTrace();
  }

}

我已从我的页面test.xhtml

调用此方法
<p:commandButton ajax="false" action="#{TestAjax.PieChart()}" value="OK"></p:commandButton>

出现此错误:

GRAVE: JDBCPieDataset - unknown data type

0 个答案:

没有答案