List of usage examples for org.jfree.chart.plot PiePlot3D getBackgroundPaint
public Paint getBackgroundPaint()
From source file:Forms.SalesChart.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed DefaultPieDataset pieDataset = new DefaultPieDataset(); String conString = "jdbc:mysql://localhost:3306/nafis"; String username = "root"; String passward = ""; String sql = "SELECT * FROM sold"; try {/*from www. jav a 2 s . com*/ Connection con = (Connection) DriverManager.getConnection(conString, username, passward); Statement s = (Statement) con.prepareStatement(sql); ResultSet rs = s.executeQuery(sql); HashMap<String, Integer> map = new HashMap<String, Integer>(); while (rs.next()) { String name = rs.getString(2); String stock = rs.getString(3); String type = rs.getString(8); Integer oldVal = map.get(type); //System.out.println(oldVal); if (oldVal == null) { map.put(type, Integer.parseInt(stock)); } else { map.put(type, oldVal + Integer.parseInt(stock)); } } for (HashMap.Entry m : map.entrySet()) { //System.out.println(m.getKey()+" "+m.getValue()); pieDataset.setValue(m.getKey() + "", Integer.parseInt(m.getValue() + "")); } } catch (Exception e) { e.printStackTrace(); } JFreeChart chart = ChartFactory.createPieChart3D("pie chart", pieDataset, true, true, false); PiePlot3D p = (PiePlot3D) chart.getPlot(); p.setStartAngle(0); p.setDirection(Rotation.CLOCKWISE); p.setForegroundAlpha(0.5f); p.getBackgroundPaint(); ChartFrame frame = new ChartFrame("Pie Chart", chart); frame.setLocationByPlatform(true); frame.setVisible(true); frame.setSize(750, 600); }