List of usage examples for org.jfree.chart.plot PiePlot setNoDataMessage
public void setNoDataMessage(String message)
null
, and sends a PlotChangeEvent to all registered listeners. From source file:UserInterface.EmployeeViewArea.ViewIssuesStatisticsJPanel.java
private static JFreeChart createPieChart(PieDataset dataset) { // chart title // data // include legend JFreeChart chart = ChartFactory.createPieChart("Reported Child Issues", dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:com.NewJFrame.java
private static JFreeChart createPieChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart("Chart Title", // chart title dataset, // data true, // include legend true, false);// ww w.j ava2 s. c o m PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {2}", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); return chart; }
From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * Creates a chart./*ww w. j a v a2 s. co m*/ * * @param dataset * the dataset. * * @return A chart. */ private static JFreeChart createPieStatusChart() { final StatusRequirementStatistics statusRequirementStatistics = new StatusRequirementStatistics(); final JFreeChart chart = statusRequirementStatistics.buildPieChart(); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); return chart; }
From source file:org.jfree.expdemo.SelectionDemo6Pie.java
private static JFreeChart createChart(final PieDataset dataset, DatasetSelectionExtension ext) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 2", // chart title dataset, // dataset true, // include legend true, false);// w w w . j a v a 2 s .co m final PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("One", new Color(160, 160, 255)); plot.setSectionPaint("Two", new Color(128, 128, 255 - 32)); plot.setSectionPaint("Three", new Color(96, 96, 255 - 64)); plot.setSectionPaint("Four", new Color(64, 64, 255 - 96)); plot.setSectionPaint("Five", new Color(32, 32, 255 - 128)); plot.setSectionPaint("Six", new Color(0, 0, 255 - 144)); plot.setNoDataMessage("No data available"); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2} percent)")); plot.setLabelBackgroundPaint(new Color(220, 220, 220)); plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}")); plot.setSimpleLabels(true); plot.setInteriorGap(0.1); //pie plots done use abstract renderers need to react to selection on our own final PieCursor cursor = new PieCursor(); ext.addSelectionChangeListener(new SelectionChangeListener() { public void selectionChanged(SelectionChangeEvent event) { for (int i = 0; i < dataset.getItemCount(); i++) { cursor.setPosition(dataset.getKey(i)); if (event.getSelectionExtension().isSelected(cursor)) { plot.setExplodePercent(cursor.key, 0.15); } else { plot.setExplodePercent(cursor.key, 0.0); } } } }); return chart; }
From source file:org.jfree.chart.demo.selection.SelectionDemo6Pie.java
private static JFreeChart createChart(final PieDataset dataset, DatasetSelectionExtension<PieCursor<String>> ext) { JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 2", dataset); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint("One", new Color(160, 160, 255)); plot.setSectionPaint("Two", new Color(128, 128, 255 - 32)); plot.setSectionPaint("Three", new Color(96, 96, 255 - 64)); plot.setSectionPaint("Four", new Color(64, 64, 255 - 96)); plot.setSectionPaint("Five", new Color(32, 32, 255 - 128)); plot.setSectionPaint("Six", new Color(0, 0, 255 - 144)); plot.setNoDataMessage("No data available"); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2} percent)")); plot.setLabelBackgroundPaint(new Color(220, 220, 220)); plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}")); plot.setSimpleLabels(true);//from w w w . j a v a 2 s . c o m plot.setInteriorGap(0.1); //pie plots done use abstract renderers need to react to selection on our own final PieCursor<String> cursor = new PieCursor<String>(); ext.addChangeListener(new SelectionChangeListener<PieCursor<String>>() { public void selectionChanged(SelectionChangeEvent<PieCursor<String>> event) { for (int i = 0; i < dataset.getItemCount(); i++) { cursor.setPosition((String) dataset.getKey(i)); if (event.getSelectionExtension().isSelected(cursor)) { plot.setExplodePercent(cursor.key, 0.15); } else { plot.setExplodePercent(cursor.key, 0.0); } } } }); return chart; }
From source file:org.gaixie.micrite.jfreechart.style.PieStyle.java
/** * ?1 ,? Familiar(30%) /*from w ww .ja v a 2 s . c o m*/ * @param chart */ public static void styleOne(JFreeChart chart) { PiePlot plot = (PiePlot) chart.getPlot(); PieDataset pd = plot.getDataset(); PieStyle.setBackground(chart); if (pd != null) { //? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); //?? for (int i = 0; i < pd.getItemCount(); i++) { int color = i % colors.length; plot.setSectionPaint(pd.getKey(i), colors[color]); } } else { plot.setNoDataMessage("NO DATA"); } }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator()); }/*from w ww . j a va 2 s . c o m*/ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } JFreeChart chart = new JFreeChart("Pie Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:org.talend.dataprofiler.chart.ChartDecorator.java
/** * // ww w . ja va2 s.c o m * DOC qiongli Comment method "decoratePiePlot". * * @param chart */ private static void decoratePiePlot(JFreeChart chart) { Font font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$ TextTitle textTitle = chart.getTitle(); // MOD msjian TDQ-5213 2012-5-7: fixed NPE if (textTitle != null) { textTitle.setFont(font); } setLegendFont(chart); // TDQ-5213~ PiePlot plot = (PiePlot) chart.getPlot(); font = new Font("Monospaced", Font.PLAIN, 10);//$NON-NLS-1$ plot.setLabelFont(font); plot.setNoDataMessage("No data available"); //$NON-NLS-1$ StandardPieSectionLabelGenerator standardPieSectionLabelGenerator = new StandardPieSectionLabelGenerator( ("{0}:{2}"), //$NON-NLS-1$ NumberFormat.getNumberInstance(), new DecimalFormat(PERCENT_FORMAT)); plot.setLabelGenerator(standardPieSectionLabelGenerator); plot.setLabelLinkPaint(Color.GRAY); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelGap(0.02D); plot.setOutlineVisible(false); plot.setMaximumLabelWidth(0.2D); plot.setCircular(false); // remove the shadow of the pie chart plot.setShadowXOffset(0); plot.setShadowYOffset(0); }
From source file:weka.core.ChartUtils.java
/** * Create a pie chart from summary data (i.e. a list of values and their * corresponding frequencies)./*from www.j av a 2 s .co m*/ * * @param values a list of values for the chart * @param freqs a list of corresponding frequencies * @param showLabels true if the chart will show labels * @param showLegend true if the chart will show a legend * @param additionalArgs optional arguments to the renderer (may be null) * @return a pie chart * @throws Exception if a problem occurs */ protected static JFreeChart getPieChartFromSummaryData(List<String> values, List<Double> freqs, boolean showLabels, boolean showLegend, List<String> additionalArgs) throws Exception { if (values.size() != freqs.size()) { throw new Exception("Number of bins should be equal to number of frequencies!"); } String plotTitle = "Pie Chart"; String userTitle = getOption(additionalArgs, "-title"); plotTitle = (userTitle != null) ? userTitle : plotTitle; String xLabel = getOption(additionalArgs, "-x-label"); xLabel = xLabel == null ? "" : xLabel; String yLabel = getOption(additionalArgs, "-y-label"); yLabel = yLabel == null ? "" : yLabel; DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < values.size(); i++) { String binLabel = values.get(i); Number freq = freqs.get(i); dataset.setValue(binLabel, freq); } JFreeChart chart = ChartFactory.createPieChart(plotTitle, // chart title dataset, // data showLegend, // include legend false, false); PiePlot plot = (PiePlot) chart.getPlot(); if (!showLabels) { plot.setLabelGenerator(null); } else { plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); // plot.setCircular(false); plot.setLabelGap(0.02); } chart.setBackgroundPaint(java.awt.Color.white); chart.setTitle(new TextTitle(plotTitle, new Font("SansSerif", Font.BOLD, 12))); return chart; }
From source file:org.jfree.chart.demo.JDBCPieChartDemo.java
public JDBCPieChartDemo(String s) { super(s);//from w w w.j a va2 s. co m PieDataset piedataset = readData(); JFreeChart jfreechart = ChartFactory.createPieChart("JDBC Pie Chart Demo", piedataset, true, true, false); jfreechart.setBackgroundPaint(Color.yellow); PiePlot pieplot = (PiePlot) jfreechart.getPlot(); pieplot.setNoDataMessage("No data available"); ChartPanel chartpanel = new ChartPanel(jfreechart); setContentPane(chartpanel); }