List of usage examples for org.jfree.chart ChartFactory createPieChart
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:br.ufba.eleicoestransparentes.view.chart.GraficoPizza.java
/** * Creates a chart./*from ww w .j a v a2 s . c o m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset, String titulo) { JFreeChart chart = ChartFactory.createPieChart(titulo, // chart title dataset, // data true, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("Nenhum dado disponibilizado"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo.java
private static JFreeChart createPieChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart title dataset, // data true, // include legend true, false);//from ww w. j av a 2 s.c om PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:com.swordlord.gozer.components.wicket.graph.GWPieChartPanel.java
public GWPieChartPanel(String id, IModel<?> model, GPieChart child) { super(id, model); DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey(); DataBindingMember dbMemberValue = child.getDataBindingMemberValue(); DataBindingManager dbManager = child.getDataBindingManager(); DefaultPieDataset dpd = new DefaultPieDataset(); List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey); List<DataRowBase> values = dbManager.getRows(dbMemberValue); String[] codes = new String[rowKeys.size()]; int[] results = new int[rowKeys.size()]; int i = 0;//w ww . j a v a 2 s . com for (DataRowBase row : rowKeys) { codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName()); i++; } i = 0; for (DataRowBase row : values) { results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName()); i++; } for (Integer j = 0; j < rowKeys.size(); j++) { dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]); } JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDrawingSupplier(child.getDrawingSupplier()); ChartImage image = new ChartImage("chart", chart, child.getWidth(200), child.getHeight(200)); add(image); }
From source file:com.swordlord.gozer.components.fop.graph.GFopPieChart.java
public GFopPieChart(IGozerFrameExtension gfe, GPieChart child) { super(gfe);//from w w w . ja va 2 s.c o m DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey(); DataBindingMember dbMemberValue = child.getDataBindingMemberValue(); DataBindingManager dbManager = child.getDataBindingManager(); DefaultPieDataset dpd = new DefaultPieDataset(); List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey); List<DataRowBase> values = dbManager.getRows(dbMemberValue); String[] codes = new String[rowKeys.size()]; int[] results = new int[rowKeys.size()]; int i = 0; for (DataRowBase row : rowKeys) { codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName()); i++; } i = 0; for (DataRowBase row : values) { results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName()); i++; } for (Integer j = 0; j < rowKeys.size(); j++) { dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]); } JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDrawingSupplier(child.getDrawingSupplier()); _image = new ChartImage("chart", chart, child.getWidth(800), child.getHeight(800)); }
From source file:org.pentaho.chart.plugin.jfreechart.chart.pie.JFreePieChartGenerator.java
protected JFreeChart doCreateChart(final ChartDocumentContext chartDocContext, final ChartTableModel data) { final ChartDocument chartDocument = chartDocContext.getChartDocument(); final String title = getTitle(chartDocument); final boolean legend = getShowLegend(chartDocument); final boolean toolTips = getShowToolTips(chartDocument); final DefaultPieDataset defaultPieDataset = datasetGeneratorFactory.createDefaultPieDataset(chartDocContext, data);//ww w . j a v a2s .c o m if (defaultPieDataset == null) { logger.error(Messages.getErrorString("JFreeChartFactoryEngine.ERROR_0001_DATASET_IS_NULL")); //$NON-NLS-1$ return null; } final JFreeChart chart = ChartFactory.createPieChart(title, defaultPieDataset, legend, toolTips, false); final PiePlot piePlot = (PiePlot) chart.getPlot(); setPlotAttributes(piePlot, chartDocument, data); return chart; }
From source file:org.simbrain.plot.piechart.PieChartGui.java
/** * Initializes frame./*from w w w .ja v a 2 s .c o m*/ */ @Override public void postAddInit() { // Generate the graph chart = ChartFactory.createPieChart("Pie Chart", this.getWorkspaceComponent().getModel().getDataset(), true, // include // legend true, false); chartPanel.setChart(chart); getWorkspaceComponent().getModel().addChartSettingsListener(new ChartSettingsListener() { public void chartSettingsUpdated() { // No implementation } }); }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo2.java
/** * Creates a sample chart./* www .ja v a 2 s .c o m*/ * * @param dataset the dataset. * * @return A chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title dataset, // dataset !legendPanelOn, // include legend true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setNoDataMessage("No data available"); for (int i = 0; i < pulloutFlag.length; i++) { //System.out.println("\""+pulloutFlag[i]+"\""); if (isPullout(i)) { Comparable key = dataset.getKey(i); plot.setExplodePercent(key, 0.30); } } plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}")); if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } setCategorySummary(dataset); return chart; }
From source file:de.main.sessioncreator.ReportingHelper.java
/** * Creates a chart//from w w w . ja v a2 s.co m */ private JFreeChart createChart(PieDataset dataset, String title) { // JFreeChart chart = ChartFactory.createPieChart3D( JFreeChart chart = ChartFactory.createPieChart(title, // chart title dataset, // data false, // include legend true, false); // PiePlot3D plot = (PiePlot3D) chart.getPlot(); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); plot.setStartAngle(90); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); return chart; }
From source file:com.liferay.portlet.polls.action.ViewChartAction.java
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {// w w w . java 2 s.c o m ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long questionId = ParamUtil.getLong(request, "questionId"); String chartType = ParamUtil.getString(request, "chartType", "pie"); CategoryDataset dataset = PollsUtil.getVotesDataset(questionId); String chartName = themeDisplay.translate("vote-results"); String xName = themeDisplay.translate("choice"); String yName = themeDisplay.translate("votes"); JFreeChart chart = null; if (chartType.equals("area")) { chart = ChartFactory.createAreaChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("horizontal_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.HORIZONTAL, true, false, false); } else if (chartType.equals("line")) { chart = ChartFactory.createLineChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else if (chartType.equals("vertical_bar")) { chart = ChartFactory.createBarChart(chartName, xName, yName, dataset, PlotOrientation.VERTICAL, true, false, false); } else { PieDataset pieData = DatasetUtilities.createPieDatasetForRow(dataset, 0); chart = ChartFactory.createPieChart(chartName, pieData, true, false, false); } response.setContentType(ContentTypes.IMAGE_JPEG); OutputStream os = response.getOutputStream(); ChartUtilities.writeChartAsJPEG(os, chart, 400, 400); return null; } catch (Exception e) { PortalUtil.sendError(e, request, response); return null; } }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo1.java
/** * Creates a chart//w ww .j a v a2s . c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); for (int i = 0; i < pulloutFlag.length; i++) { //System.out.println("\""+pulloutFlag[i]+"\""); if (isPullout(i)) { Comparable key = dataset.getKey(i); plot.setExplodePercent(key, 0.30); } } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); setCategorySummary(dataset); if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } return chart; }