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:UserInterface.PublisherRole.ViewUserHabitsJPanel.java
private static JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("User Habits", // chart title dataset, // data false, // no legend true, // tooltips false // no URL generation );//from www. ja va 2s. c om // 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(" ", 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:Visuals.PieChart.java
public ChartPanel drawPieChart() { DefaultPieDataset piedataset = new DefaultPieDataset(); if (riskCount == 0) { title = ""; piedataset.setValue(noVulnerabilities, new Integer(1)); } else {/*from w w w . jav a 2s. c o m*/ piedataset.setValue(lowValue, new Integer(low)); piedataset.setValue(mediumValue, new Integer(medium)); piedataset.setValue(highValue, new Integer(high)); piedataset.setValue(criticalValue, new Integer(critical)); } JFreeChart piechart = ChartFactory.createPieChart(title, // Title piedataset, // Dataset true, // Show legend true, // Use tooltips false // Generate URLs ); PiePlot plot = (PiePlot) piechart.getPlot(); //plot.setSimpleLabels(true); if (riskCount == 0) { plot.setSectionPaint(noVulnerabilities, new Color(47, 196, 6)); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); piechart.removeLegend(); } else { plot.setSectionPaint(criticalValue, new Color(230, 27, 27)); plot.setSectionPaint(highValue, new Color(230, 90, 27)); plot.setSectionPaint(mediumValue, new Color(85, 144, 176)); plot.setSectionPaint(lowValue, new Color(230, 219, 27)); } if (isMain) { piechart.removeLegend(); } plot.setBackgroundPaint(new Color(210, 234, 243)); ChartPanel chartPanel = new ChartPanel(piechart); chartPanel.setEnabled(false); return chartPanel; }
From source file:picocash.components.panel.statistic.IncomeByCategoryStatistic.java
private void init() { this.title = "Income"; 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()); piechart.setBorderVisible(false);/* w w w.j a v a 2 s.c o m*/ piechart.setAntiAlias(true); ((PiePlot) piechart.getPlot()).setLabelGenerator(null); 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, "aligny top"); }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreePieChartData.java
@Override public JFreeChart getJFreeChart() { DefaultPieDataset pieDataset = makeDataSet(); JFreeChart chart = ChartFactory.createPieChart(title, // Title pieDataset, // Dataset true // Show legend , false, false);//from www. j a va 2 s. c om PiePlot plot = (PiePlot) chart.getPlot(); StandardPieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0} ({2})"); plot.setLabelGenerator(gen); plot.setMaximumLabelWidth(0.07); plot.setLabelFont(plot.getLabelFont().deriveFont(9.0F)); LegendTitle leg = chart.getLegend(); leg.setPosition(RectangleEdge.RIGHT); if (!colours.isEmpty()) { String legends[] = ds.getLegends(); for (int i = 0; i < ds.getNumSets(); i++) { if (legends != null && legends.length > i && colours.size() > i) { Color c = colours.get(i); plot.setSectionPaint(legends[i], c); } } } return chart; }
From source file:org.gephi.desktop.partition.PartitionPie.java
public void setup(Partition partition) { data = new DefaultPieDataset(); for (Part p : partition.getParts()) { data.setValue(p.getDisplayName(), p.getPercentage()); }/*from w w w. j ava2s .c o m*/ final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false); chart.setTitle(new TextTitle()); chart.setBackgroundPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setShadowPaint(null); //plot.setSimpleLabels(true); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlineStroke(null); plot.setLabelShadowPaint(null); plot.setOutlineVisible(false); plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10)); plot.setLabelPaint(Color.BLACK); //plot.setLabelGap(0.05); plot.setCircular(true); plot.setBackgroundPaint(null); plot.setBackgroundAlpha(1f); for (Part p : partition.getParts()) { plot.setSectionPaint(p.getDisplayName(), p.getColor()); } chartPanel = new ChartPanel(chart, true); chartPanel.setOpaque(false); chartPanel.setPopupMenu(null); add(chartPanel, BorderLayout.CENTER); }
From source file:org.datacleaner.widgets.result.CategorizationResultSwingRenderer.java
@Override public JComponent render(CategorizationResult analyzerResult) { final DefaultPieDataset dataset = new DefaultPieDataset(); final Collection<String> categoryNames = analyzerResult.getCategoryNames(); for (String categoryName : categoryNames) { final Number count = analyzerResult.getCategoryCount(categoryName); dataset.setValue(categoryName, count); }/*from w w w . java 2 s . c o m*/ final DefaultTableModel model = prepareModel(analyzerResult, dataset); final DCTable table = new DCTable(model); table.setColumnControlVisible(false); table.setRowHeight(22); final JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, false, false); ChartUtils.applyStyles(chart); final ChartPanel chartPanel = ChartUtils.createPanel(chart, false); final DCPanel leftPanel = WidgetUtils.decorateWithShadow(chartPanel); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new VerticalLayout()); rightPanel.add(WidgetUtils.decorateWithShadow(table.toPanel())); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.setOpaque(false); split.add(leftPanel); split.add(rightPanel); split.setDividerLocation(550); return split; }
From source file:gui.statistic.JChartPanel.java
protected static JFreeChart createPieChart() { pieDataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart("", // Title pieDataset, false, true, false); chart.setBackgroundPaint(Color.WHITE); // CategoryPlot plot = (CategoryPlot) chart.getPlot(); // plot.setBackgroundPaint(Color.LIGHT_GRAY); // plot.setDomainGridlinePaint(Color.WHITE); // plot.setRangeGridlinePaint(Color.WHITE); // plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); //plot.setDomainCrosshairVisible(true); //plot.setRangeCrosshairVisible(true); return chart; }
From source file:jdefects.view.dialogs.ChartDisplayDialog.java
/** * Generate the pie chart using JFreeChart library * @param dataset//from ww w . jav a 2 s.co m * dataset to display in the chart * @return * the pie chart */ private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(LanguageContent.chart_title, dataset, true, true, false); return chart; }
From source file:cz.cuni.mff.ksi.jinfer.attrstats.JFCWrapper.java
private static JFreeChart createChart(final String title, final PieDataset dataset) { final JFreeChart chart = ChartFactory.createPieChart(title, dataset, false, true, false); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true);/*from w ww. jav a2s . co m*/ plot.setLabelGap(0.02); return chart; }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.PieChart.java
@Override protected JFreeChart createGraph() { PieDataset dataset = createDataset(); return ChartFactory.createPieChart(graphTitle, dataset, true, true, false); }