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:com.voterData.graph.Graph.java
public static JFreeChart getRaceDistChart(ArrayList<VoterDetails> voterDetList) { DefaultPieDataset dataset = new DefaultPieDataset(); for (VoterDetails voterDetObj : voterDetList) { dataset.setValue(voterDetObj.getRace_code(), Double.parseDouble(voterDetObj.getVoter_reg_num())); }/* w w w .j av a 2s. co m*/ boolean legend = true; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart("Race Distribution of Mecklenburg County", dataset, legend, tooltips, urls); //chart.setBorderPaint(Color.GREEN); //chart.setBorderStroke(new BasicStroke(5.0f)); //chart.setBorderVisible(true); return chart; }
From source file:clientesbac.frmConsultaClientes.java
public void pastel() { // Fuente de Datos DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Regular", 40); data.setValue("Corporativo", 20); data.setValue("Adulto Mayor", 15); data.setValue("Embarazada", 15); data.setValue("Discapacitado", 10); // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart("Grfico de pastel por tipo de Cliente", data, true, true, false);//from w w w . j a va 2 s . c o m // Mostrar Grafico ChartFrame frame = new ChartFrame("Reporte", chart); frame.pack(); frame.setVisible(true); }
From source file:UserInterface.CentreForDiseaseControl.AddDiseaseJPanel.java
public void displayPieChart(String diseaseName) { String sName = ""; int winnerState = 0; int totalQuantityConsumedInState = 0; DefaultPieDataset pieDataset = new DefaultPieDataset(); for (PHDEnterprise phdEnterprise : enterprise.getPhdList()) { String stateName = phdEnterprise.getStateName(); for (Order order : enterprise.getMasterOrderCatalog().getOrderList()) { if (order.getSite().getStateName().equals(stateName)) { for (OrderItem orderItem : order.getOrderItemList()) { if (orderItem.getVaccine().getDisease().getDiseaseName().equals(diseaseName) && orderItem.getIsOrderItemApprovedByCdc().equals("Approved")) { totalQuantityConsumedInState = totalQuantityConsumedInState + orderItem.getTotalQuantity(); if (totalQuantityConsumedInState > winnerState) { winnerState = totalQuantityConsumedInState; sName = stateName; }// w w w .j ava2 s. c o m } } } } pieDataset.setValue(stateName, totalQuantityConsumedInState); totalQuantityConsumedInState = 0; } JFreeChart chart = ChartFactory.createPieChart("Pie Chart", pieDataset, true, true, true); PiePlot p = (PiePlot) chart.getPlot(); ChartFrame frame = new ChartFrame("Disease Summary", chart); frame.setVisible(true); frame.setSize(450, 500); stateNameJTextField.setText(sName); }
From source file:icaro.aplicaciones.recursos.recursoEstadistica.jFreeChart.demo.PieChartDemo1.java
/** * Creates a chart./*ww w . j a va 2 s . c o m*/ * * @param dataset the dataset. * * @return A chart. */ private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation ); // set a custom background for the chart chart.setBackgroundPaint( new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); // customise the title position and font TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); // plot.setOutlineVisible(false); // use gradients and white borders for the section colours plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); // customise the section label appearance plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); return chart; }
From source file:View.RIM.Components.PieChart.java
private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(null, // chart title dataset, // data true, // include legend true, false);/* www . j a v a 2s . com*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:info.mikaelsvensson.devtools.analysis.localaccesslog.LocalAccessLogReportGenerator.java
@Override public void generateReport(File outputFile, ReportPrinter reportPrinter) throws FileNotFoundException { final PrintStream ps = new PrintStream(outputFile); final Collection<LocalAccessLogSample> allSamples = _log.getSamples(); Map<String, Collection<LocalAccessLogSample>> samplesByTestSession = SampleCollector.COLLECTOR_BY_SESSION_DATE .getFilteredAndGrouped(allSamples); for (Map.Entry<String, Collection<LocalAccessLogSample>> sessionEntry : samplesByTestSession.entrySet()) { final Collection<LocalAccessLogSample> sessionSamples = sessionEntry.getValue(); Map<String, Collection<LocalAccessLogSample>> samples = SAMPLE_COLLECTOR .getFilteredAndGrouped(sessionSamples); String[][] data = new String[samples.size() + 1][]; int i = 0; int sumCount = 0; final DefaultPieDataset dataset = new DefaultPieDataset(); final JFreeChart chart = ChartFactory.createPieChart( "Status Codes For Session " + sessionEntry.getKey(), dataset, true, false, Locale.ENGLISH); final File chartFile = new File(outputFile.getAbsolutePath() + "." + StringUtils.remove(sessionEntry.getKey(), ':').replace(' ', '-') + ".png"); final PiePlot plot = (PiePlot) chart.getPlot(); for (Map.Entry<String, Collection<LocalAccessLogSample>> entry : samples.entrySet()) { final Collection<LocalAccessLogSample> responseCodeSamples = entry.getValue(); final int count = responseCodeSamples.size(); data[i++] = new String[] { entry.getKey(), ToStringUtil.toString(count), ToStringUtil.toString(_log.calculateAverage(responseCodeSamples)), ToStringUtil.toString(_log.calculateMin(responseCodeSamples)), ToStringUtil.toString(_log.calculateMax(responseCodeSamples)) }; sumCount += count;// w w w . j a v a 2 s .c o m final String label = entry.getKey() + " (" + count + " reqs)"; dataset.setValue(label, count); plot.setSectionPaint(label, entry.getKey().equals("200") ? Color.GREEN : Color.RED); } data[i] = new String[] { "All", ToStringUtil.toString(sumCount), ToStringUtil.toString(_log.calculateAverage(sessionSamples)), ToStringUtil.toString(_log.calculateMin(sessionSamples)), ToStringUtil.toString(_log.calculateMax(sessionSamples)) }; reportPrinter.printTable(ps, sessionEntry.getKey(), 10, new String[] { "Status Code", "# Requests", "Avg [ms]", "Min [ms]", "Max [ms]" }, data, null); if (sumCount > NUMBER_OF_REQUESTS_IN_SHORT_TEST) { try { ChartUtilities.saveChartAsPNG(chartFile, chart, 500, 500); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } } ps.close(); }
From source file:Software_Jframes.chart.java
public void piechart_customer(JDesktopPane jDesktopPane1, String pid) { DefaultPieDataset piedataset = new DefaultPieDataset(); int cost_total = 0; try {//from w w w. ja v a2 s.c om ResultSet rs = db.statement().executeQuery("select * from cus_payment where Project_id='" + pid + "' "); while (rs.next()) { String cost = rs.getString("Amount"); int cost_int1 = Integer.parseInt(cost); cost_total = cost_total + cost_int1; } } catch (Exception e) { e.printStackTrace(); } piedataset.setValue("Amount Received", cost_total); piedataset.setValue("Amount to be Received", 7854); JFreeChart chart = ChartFactory.createPieChart("Costs for Project", piedataset, true, true, true); PiePlot p = (PiePlot) chart.getPlot(); p.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); jDesktopPane1.add(panel).setSize(500, 230); }
From source file:org.jfree.chart.demo.ChartTiming1.java
/** * Runs the timing.//from w w w .j a v a 2 s . c o m */ public void run() { this.finished = false; // create a dataset... final DefaultPieDataset data = new DefaultPieDataset(); data.setValue("One", new Double(10.3)); data.setValue("Two", new Double(8.5)); data.setValue("Three", new Double(3.9)); data.setValue("Four", new Double(3.9)); data.setValue("Five", new Double(3.9)); data.setValue("Six", new Double(3.9)); // create a pie chart... final boolean withLegend = true; final JFreeChart chart = ChartFactory.createPieChart("Testing", data, withLegend, true, false); final BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); final Graphics2D g2 = image.createGraphics(); final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300); // set up the timer... final Timer timer = new Timer(10000, this); timer.setRepeats(false); int count = 0; timer.start(); while (!this.finished) { chart.draw(g2, chartArea, null, null); System.out.println("Charts drawn..." + count); if (!this.finished) { count++; } } System.out.println("DONE"); }
From source file:picocash.components.panel.statistic.ExpenseByCategoryStatistic.java
private void init() { this.title = "Expense"; this.dataset = new DefaultPieDataset(); this.chartPanel = new JXPanel(new MigLayout("fill, insets 0 0 0 0")); final JFreeChart piechart = ChartFactory.createPieChart(title, dataset, true, true, Locale.getDefault()); ((PiePlot) piechart.getPlot()).setLabelGenerator(null); piechart.setBorderVisible(false);/*from w ww . j a va2s. co m*/ piechart.setAntiAlias(true); ChartPanel chart = new ChartPanel(piechart, 300, 300, 200, 200, 400, 400, false, false, false, false, false, true); chart.getChart().getPlot().setBackgroundAlpha(0); chart.getChart().getPlot().setOutlineVisible(false); this.chartPanel.setOpaque(false); this.chartPanel.add(chart, "growx, aligny top"); }