Hii..i have developed an application and i want to display the values from the database in the piechart/barchart but the problem is that it is taking only 5 values from database and i have 10 values in it.how to display all values. plzz help..itz urgent.. my code is:
try {
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:odbc:LeadManagementSystem", "", ""); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("SELECT * from ProjectDetails"); while (rs.next()) { dataset.setValue(rs.getInt("NoOfLeads"), "NoOfLeads", rs.getString("ProjectName")); } JFreeChart chart = ChartFactory.createBarChart3D("LEAD REPORT (PROJECT)", "Project Name", "Leads", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.yellow); chart.getTitle().setPaint(Color.blue); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); ApplicationFrame f = new ApplicationFrame("AllocationDB"); f.setContentPane(chartPanel); f.pack(); f.setVisible(true); try { ChartUtilities.saveChartAsJPEG(new File("C:/chart1.jpg"), chart, 400, 300); } catch (IOException e) { System.out.println("Problem in creating chart."); } } catch (Exception e) { }
Ads