List of usage examples for org.jfree.chart.labels StandardPieItemLabelGenerator StandardPieItemLabelGenerator
public StandardPieItemLabelGenerator(String labelFormat, NumberFormat numberFormat,
NumberFormat percentFormat)
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getNoChapterPie() { JFreeChart chart;/*from w w w.ja va 2 s .c o m*/ DefaultPieDataset ds = new DefaultPieDataset(); Integer numChapter = Helpers.getGroup("Chapter").getNumMembers(); ds.setValue("in a chapter", numChapter); ds.setValue("not in a chapter", Helpers.getGroup("Org").getNumMembers() - numChapter); chart = ChartFactory.createPieChart("Chapter Membership Breakdown", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getRankPie() { JFreeChart chart;// w w w. j a va2 s. c o m DefaultPieDataset ds = new DefaultPieDataset(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); int numUsers = Helpers.getGroup("Org").getNumMembers(); ds.setValue("Regular Members", numRegular); ds.setValue("Associate Members", numAssociate); ds.setValue("Mailing list Members", numUsers - numAssociate - numRegular); chart = ChartFactory.createPieChart("Status breakdown for " + numUsers + " members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getChapterRankPie(Session s, String url) { String[] path = url.split("/"); String lastPiece = path[path.length - 1]; Integer chapterId = new Integer(lastPiece.substring(0, lastPiece.length() - 4)); GroupChapterModel chapter = (GroupChapterModel) s.get(GroupChapterModel.class, chapterId); JFreeChart chart;// www . j a v a2s . co m DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) as num from roles r1, roles r2 " + "where r1.userid=r2.userid and r1.groupid=? and r1.level='m' and r2.level='m' " + "and r1.end is null and r2.end is null and r2.groupid=?"; int numRegular = ((Integer) s.createSQLQuery(query).addScalar("num", Hibernate.INTEGER) .setInteger(0, chapter.getId()).setInteger(1, Helpers.getGroup("Regular").getId()).list().get(0)) .intValue(); int numAssociate = ((Integer) s.createSQLQuery(query).addScalar("num", Hibernate.INTEGER) .setInteger(0, chapter.getId()).setInteger(1, Helpers.getGroup("Associate").getId()).list().get(0)) .intValue(); int numUsers = chapter.getNumMembers(); ds.setValue("Regular Members", numRegular); ds.setValue("Associate Members", numAssociate); ds.setValue("Mailing list Members", numUsers - numAssociate - numRegular); chart = ChartFactory.createPieChart("Status breakdown for " + numUsers + " chapter members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getStudentPie(Session s) { JFreeChart chart;/*from w w w . ja v a 2 s .c o m*/ DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.student='y'"; int numStudent = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.student='n'"; int numNonStudent = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("Student users", numStudent); ds.setValue("Unspecified", numAssociate + numRegular - numStudent - numNonStudent); ds.setValue("Non-Student users", numNonStudent); chart = ChartFactory.createPieChart("Student Status Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getLanguagePie(Session s) { JFreeChart chart;/*ww w .j av a 2 s .c om*/ DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.language='en'"; int numEn = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.language='fr'"; int numFr = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("English", numEn); ds.setValue("Unspecified", numAssociate + numRegular - numEn - numFr); ds.setValue("French", numFr); chart = ChartFactory.createPieChart("Preferred Language Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getGenderPie(Session s) { JFreeChart chart;/*from ww w .j a va 2 s.c o m*/ DefaultPieDataset ds = new DefaultPieDataset(); String query = "select count(*) from UserModel as u where u.gender='f'"; int numFemale = ((Long) s.createQuery(query).list().get(0)).intValue(); query = "select count(*) from UserModel as u where u.gender='m'"; int numMale = ((Long) s.createQuery(query).list().get(0)).intValue(); int numRegular = Helpers.getGroup("Regular").getNumMembers(); int numAssociate = Helpers.getGroup("Associate").getNumMembers(); ds.setValue("Female users", numFemale); ds.setValue("Unspecified", numAssociate + numRegular - numFemale - numMale); ds.setValue("Male users", numMale); chart = ChartFactory.createPieChart("Gender Breakdown for Associate/Regular members", ds, false, false, false); PiePlot plot = ((PiePlot) chart.getPlot()); StandardPieItemLabelGenerator n = new StandardPieItemLabelGenerator("{0} = {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0.0%")); plot.setLabelGenerator(n); return chart; }