List of usage examples for org.jfree.chart ChartFactory createRingChart
public static JFreeChart createRingChart(String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:de.chott.jfreechartsample.service.ChartService.java
/** * Diese Methode erstellt ein RingChart aus den RingChartDaten. * // ww w . j a v a 2 s . c o m * @return Das fertige RingChart. */ private JFreeChart createRingChart() { DefaultPieDataset dataSet = new DefaultPieDataset(); for (RingChartData data : ringChartDataService.loadAll()) { dataSet.setValue(data.getSecurity(), data.getWeighting()); } JFreeChart chart = ChartFactory.createRingChart("", dataSet, true, false, Locale.GERMANY); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.RingChartDemo1.java
/** * Creates a chart./*from w ww . j a v a 2s .c o m*/ * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createRingChart(chartTitle, // chart title dataset, // data !legendPanelOn, // include legend true, false); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); 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); } } if (rotateOn) { Rotator rotator = new Rotator(plot); rotator.start(); } setCategorySummary(dataset); return chart; }
From source file:org.datacleaner.widgets.result.UniqueKeyCheckAnalyzerResultSwingRenderer.java
@Override public JComponent render(UniqueKeyCheckAnalyzerResult result) { final int nullCount = result.getNullCount(); final int nonUniqueCount = result.getNonUniqueCount(); final DefaultKeyedValues keyedValues = new DefaultKeyedValues(); keyedValues.addValue("Unique keys", result.getUniqueCount()); final List<Title> subTitles = new ArrayList<Title>(); subTitles.add(new ShortTextTitle("Row count: " + result.getRowCount())); subTitles.add(new ShortTextTitle("Unique key count: " + result.getUniqueCount())); if (nonUniqueCount > 0) { keyedValues.addValue("Non-unique keys", nonUniqueCount); subTitles.add(new ShortTextTitle("Non-unique key count: " + nonUniqueCount)); }/* ww w . j av a 2 s. co m*/ final String title; if (nullCount == 0) { title = "Unique and non-unique keys"; } else { keyedValues.addValue(LabelUtils.NULL_LABEL, nullCount); title = "Unique, non-unique and <null> keys"; subTitles.add(new ShortTextTitle("<null> key count: " + result.getNullCount())); } final DefaultPieDataset dataset = new DefaultPieDataset(keyedValues); final JFreeChart chart = ChartFactory.createRingChart(title, dataset, true, true, false); chart.setSubtitles(subTitles); ChartUtils.applyStyles(chart); ChartPanel chartPanel = ChartUtils.createPanel(chart, false); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel)); final Map<String, Integer> samples = result.getNonUniqueSamples(); if (samples == null || samples.isEmpty()) { return leftPanel; } final DefaultTableModel samplesTableModel = new DefaultTableModel(new String[] { "Key", "Count" }, 0); for (final Entry<String, Integer> entry : samples.entrySet()) { final String key = entry.getKey(); final Integer count = entry.getValue(); samplesTableModel.addRow(new Object[] { key, count }); } final DCTable samplesTable = new DCTable(samplesTableModel); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(DCLabel.dark("Sample non-unique keys:")); rightPanel.add(samplesTable.toPanel(), BorderLayout.CENTER); 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:org.eobjects.datacleaner.widgets.result.UniqueKeyCheckAnalyzerResultSwingRenderer.java
@Override public JComponent render(UniqueKeyCheckAnalyzerResult result) { final int nullCount = result.getNullCount(); final int nonUniqueCount = result.getNonUniqueCount(); final DefaultKeyedValues keyedValues = new DefaultKeyedValues(); keyedValues.addValue("Unique keys", result.getUniqueCount()); final List<Title> subTitles = new ArrayList<Title>(); subTitles.add(new ShortTextTitle("Row count: " + result.getRowCount())); subTitles.add(new ShortTextTitle("Unique key count: " + result.getUniqueCount())); if (nonUniqueCount > 0) { keyedValues.addValue("Non-unique keys", nonUniqueCount); subTitles.add(new ShortTextTitle("Non-unique key count: " + nonUniqueCount)); }//from ww w . j av a 2 s . co m final String title; if (nullCount == 0) { title = "Unique and non-unique keys"; } else { keyedValues.addValue(LabelUtils.NULL_LABEL, nullCount); title = "Unique, non-unique and <null> keys"; subTitles.add(new ShortTextTitle("<null> key count: " + result.getNullCount())); } final DefaultPieDataset dataset = new DefaultPieDataset(keyedValues); final JFreeChart chart = ChartFactory.createRingChart(title, dataset, true, true, false); chart.setSubtitles(subTitles); ChartUtils.applyStyles(chart); ChartPanel chartPanel = new ChartPanel(chart); final DCPanel leftPanel = new DCPanel(); leftPanel.setLayout(new VerticalLayout()); leftPanel.add(WidgetUtils.decorateWithShadow(chartPanel, true, 4)); final Map<String, Integer> samples = result.getNonUniqueSamples(); if (samples == null || samples.isEmpty()) { return leftPanel; } final DefaultTableModel samplesTableModel = new DefaultTableModel(new String[] { "Key", "Count" }, 0); for (final Entry<String, Integer> entry : samples.entrySet()) { final String key = entry.getKey(); final Integer count = entry.getValue(); samplesTableModel.addRow(new Object[] { key, count }); } final DCTable samplesTable = new DCTable(samplesTableModel); final DCPanel rightPanel = new DCPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(DCLabel.dark("Sample non-unique keys:")); rightPanel.add(samplesTable.toPanel(), BorderLayout.CENTER); 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:org.adempiere.apps.graph.GraphBuilder.java
private JFreeChart createRingChart() { final JFreeChart chart = ChartFactory.createRingChart(m_goal.getMeasure().getName(), pieDataset, false, true, true);/* ww w. j a v a 2s . com*/ return chart; }
From source file:eu.delving.sip.base.ReportChartHelper.java
public static JComponent createLinkChart(DataSet dataSet, String prefix, Map<RecDef.Check, LinkFile.LinkStats> linkStatsMap) { JPanel p = new JPanel(new GridLayout(0, 1)); for (Map.Entry<RecDef.Check, LinkFile.LinkStats> entry : linkStatsMap.entrySet()) { JPanel pp = new JPanel(new GridLayout(1, 0)); pp.setBorder(BorderFactory.createTitledBorder(entry.getKey().toString())); for (Map.Entry<String, PieDataset> datasetEntry : entry.getValue().createPies().entrySet()) { JFreeChart chart = ChartFactory.createRingChart(datasetEntry.getKey(), datasetEntry.getValue(), true, false, Locale.getDefault()); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelGenerator(null); plot.setNoDataMessage("No data available"); plot.setSectionDepth(0.34999999999999998D); plot.setCircular(true);/*from w w w. ja v a 2 s . c o m*/ plot.setLabelGap(0.02D); pp.add(new ChartPanel(chart)); } p.add(pp); } return p; }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo.java
private static JFreeChart createRingChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createRingChart("Ring Chart Demo 1", // chart title dataset, // data true, // include legend true, false);/*from w w w .jav a2 s.co m*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setNoDataMessage("No data available"); return chart; }
From source file:org.exist.xquery.modules.jfreechart.JFreeChartFactory.java
/** * Create JFreeChart graph using the supplied parameters. * * @param chartType One of the many chart types. * @param conf Chart configuration// w ww . jav a 2 s . c om * @param is Inputstream containing chart data * @return Initialized chart or NULL in case of issues. * @throws IOException Thrown when a problem is reported while parsing XML data. */ public static JFreeChart createJFreeChart(String chartType, Configuration conf, InputStream is) throws XPathException { logger.debug("Generating " + chartType); // Currently two dataset types supported CategoryDataset categoryDataset = null; PieDataset pieDataset = null; try { if ("PieChart".equals(chartType) || "PieChart3D".equals(chartType) || "RingChart".equals(chartType)) { logger.debug("Reading XML PieDataset"); pieDataset = DatasetReader.readPieDatasetFromXML(is); } else { logger.debug("Reading XML CategoryDataset"); categoryDataset = DatasetReader.readCategoryDatasetFromXML(is); } } catch (IOException ex) { throw new XPathException(ex.getMessage()); } finally { try { is.close(); } catch (IOException ex) { // } } // Return chart JFreeChart chart = null; // Big chart type switch if ("AreaChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createAreaChart(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("BarChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createBarChart(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("BarChart3D".equalsIgnoreCase(chartType)) { chart = ChartFactory.createBarChart3D(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("LineChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createLineChart(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("LineChart3D".equalsIgnoreCase(chartType)) { chart = ChartFactory.createLineChart3D(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("MultiplePieChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createMultiplePieChart(conf.getTitle(), categoryDataset, conf.getOrder(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setPieChartParameters(chart, conf); } else if ("MultiplePieChart3D".equalsIgnoreCase(chartType)) { chart = ChartFactory.createMultiplePieChart3D(conf.getTitle(), categoryDataset, conf.getOrder(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setPieChartParameters(chart, conf); } else if ("PieChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createPieChart(conf.getTitle(), pieDataset, conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setPieChartParameters(chart, conf); } else if ("PieChart3D".equalsIgnoreCase(chartType)) { chart = ChartFactory.createPieChart3D(conf.getTitle(), pieDataset, conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setPieChartParameters(chart, conf); } else if ("RingChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createRingChart(conf.getTitle(), pieDataset, conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setPieChartParameters(chart, conf); } else if ("SpiderWebChart".equalsIgnoreCase(chartType)) { SpiderWebPlot plot = new SpiderWebPlot(categoryDataset); if (conf.isGenerateTooltips()) { plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); } chart = new JFreeChart(conf.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); if (conf.isGenerateLegend()) { LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); } else { TextTitle subTitle = new TextTitle(" "); subTitle.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(subTitle); } setCategoryChartParameters(chart, conf); } else if ("StackedAreaChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createStackedAreaChart(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("StackedBarChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createStackedBarChart(conf.getTitle(), conf.getDomainAxisLabel(), conf.getRangeAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("StackedBarChart3D".equalsIgnoreCase(chartType)) { chart = ChartFactory.createStackedBarChart3D(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else if ("WaterfallChart".equalsIgnoreCase(chartType)) { chart = ChartFactory.createWaterfallChart(conf.getTitle(), conf.getCategoryAxisLabel(), conf.getValueAxisLabel(), categoryDataset, conf.getOrientation(), conf.isGenerateLegend(), conf.isGenerateTooltips(), conf.isGenerateUrls()); setCategoryChartParameters(chart, conf); } else { logger.error("Illegal chartype. Choose one of " + "AreaChart BarChart BarChart3D LineChart LineChart3D " + "MultiplePieChart MultiplePieChart3D PieChart PieChart3D " + "RingChart SpiderWebChart StackedAreaChart StackedBarChart " + "StackedBarChart3D WaterfallChart"); } setCommonParameters(chart, conf); return chart; }
From source file:org.efs.openreports.engine.ChartReportEngine.java
private static JFreeChart createRingChart(ReportChart reportChart, ChartValue[] values) { PieDataset dataset = createPieDataset(values); JFreeChart chart = ChartFactory.createRingChart(reportChart.getTitle(), dataset, reportChart.isShowLegend(), true, false);//from w ww . ja v a 2s . c o m return chart; }
From source file:org.pentaho.reporting.engine.classic.extensions.legacy.charts.LegacyChartType.java
private JFreeChart createChart(final Expression aExpression) { if (aExpression instanceof BarLineChartExpression) { final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer()); plot.setRenderer(1, new LineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("Bar Line Chart", plot); }//from ww w .j a va 2 s . com if (aExpression instanceof RingChartExpression) { return ChartFactory.createRingChart("Ring Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof AreaChartExpression) { return ChartFactory.createAreaChart("Area Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof BarChartExpression) { return ChartFactory.createBarChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof LineChartExpression) { return ChartFactory.createLineChart("Line Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof MultiPieChartExpression) { return ChartFactory.createMultiplePieChart("Multi Pie Chart", createDataset(), TableOrder.BY_COLUMN, true, false, false);// NON-NLS } if (aExpression instanceof PieChartExpression) { return ChartFactory.createPieChart("Pie Chart", createPieDataset(), true, false, false);// NON-NLS } if (aExpression instanceof WaterfallChartExpressions) { return ChartFactory.createWaterfallChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.HORIZONTAL, true, false, false);// NON-NLS } if (aExpression instanceof BubbleChartExpression) { return ChartFactory.createBubbleChart("Bubble Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ExtendedXYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof ScatterPlotChartExpression) { return ChartFactory.createScatterPlot("Scatter Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYAreaLineChartExpression) { final NumberAxis catAxis = new NumberAxis("Range");// NON-NLS final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS final XYPlot plot = new XYPlot(createXYZDataset(), catAxis, barsAxis, new XYAreaRenderer()); plot.setRenderer(1, new XYLineAndShapeRenderer()); // add lines dataset and axis to plot plot.setDataset(1, createXYZDataset()); plot.setRangeAxis(1, linesAxis); // map lines to second axis plot.mapDatasetToRangeAxis(1, 1); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set location of second axis plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); return new JFreeChart("XY Area Line Chart", plot);// NON-NLS } if (aExpression instanceof XYAreaChartExpression) { return ChartFactory.createXYAreaChart("XY Area Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYBarChartExpression) { return XYBarChartExpression.createXYBarChart("XY Bar Chart", "X", false, "Y", createIntervalXYDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof XYLineChartExpression) { return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL, true, false, false);// NON-NLS } if (aExpression instanceof RadarChartExpression) { final SpiderWebPlot plot = new SpiderWebPlot(createDataset()); return new JFreeChart("Radar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } if (aExpression instanceof ThermometerChartExpression) { final DefaultValueDataset dataset = new DefaultValueDataset(new Double(65.0)); final ThermometerPlot plot = new ThermometerPlot(dataset); return new JFreeChart("Thermometer Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } return null; }