List of usage examples for org.jfree.chart.plot PiePlot setDataset
public void setDataset(PieDataset dataset)
From source file:org.openfaces.component.chart.impl.plots.MultiplePiePlotAdapter.java
public MultiplePiePlotAdapter(CategoryDataset ds, TableOrder order, Chart chart, PieChartView view) { super(ds);// www . j a v a2 s . c om TextTitle seriesTitle = getSeriesTitle(chart); getPieChart().setTitle(seriesTitle); PiePlot piePlot = (PiePlot) getPieChart().getPlot(); piePlot.setDataset(new CategoryToPieDataset(ds, order, 0)); setDataExtractOrder(order); if (view.isEnable3D()) { new PiePlot3DAdapter(piePlot, ds, order, view, chart); } else { new PiePlotAdapter(piePlot, ds, order, view, chart); } addConfigurator(new PlotColorsConfigurator()); configure(view); }
From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloPieChart.java
protected JFreeChart createGraph() { JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, true, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDataset(dataset); plot.setOutlinePaint(null);//from w ww .java 2 s .co m plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No Klocwork data found."); plot.setCircular(false); plot.setLabelGap(0.02); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}")); // Set colours //plot.setOutlinePaint("New", new Color(200, 0, 0)); int i = 0; if (kloConfig.getBuildGraph().isNeww() && kloReport.getNeww() > 0) { plot.setSectionPaint(plot.getDataset().getKey(i), new Color(200, 0, 0)); i++; } if (kloConfig.getBuildGraph().isExisting() && kloReport.getExisting() > 0) { plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 0, 200)); i++; } if (kloConfig.getBuildGraph().isFixed() && kloReport.getFixed() > 0) { plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 200, 0)); } //plot.setOutlinePaint("Existing", new Color(0, 0, 200)); //plot.setOutlinePaint("Fixed", new Color(0, 200, 0)); return chart; }
From source file:dbseer.gui.chart.DBSeerChartRefreshWorker.java
@Override protected void process(List<DBSeerChart> list) { for (DBSeerChart chart : list) { if (chart.getName().equalsIgnoreCase("TransactionMix")) { DefaultPieDataset dataset = chart.getPieDataset(); PiePlot piePlot = (PiePlot) chart.getChart().getPlot(); piePlot.setDataset(dataset); } else {/* ww w. j a va2s .c o m*/ XYSeriesCollection dataset = chart.getXYDataset(); chart.getChart().getXYPlot().setDataset(dataset); } } }
From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java
@Override public void updateChartForUserType(JFreeChart userTypeChart, List<TipoUsuarioEstadistica> usuarioEstadisticas) { PieDataset pieDataset = createDataForUserType(usuarioEstadisticas); PiePlot piePlot = (PiePlot) userTypeChart.getPlot(); piePlot.setDataset(pieDataset); }
From source file:com.itemanalysis.jmetrik.graph.piechart.PieChartPanel.java
public void updateDefaultPieDataset(TwoWayTable table) { DefaultPieDataset dataset = new DefaultPieDataset(); Iterator<Comparable<?>> rowIter = table.rowValuesIterator(); Iterator<Comparable<?>> colIter = null; Comparable<?> r = null; Comparable<?> c = null; while (rowIter.hasNext()) { r = rowIter.next();//w ww . jav a 2s . co m colIter = table.colValuesIterator(); while (colIter.hasNext()) { c = colIter.next(); dataset.setValue(c.toString(), table.getCount(r, c)); } } PiePlot plot = (PiePlot) chart.getPlot(); plot.setDataset(dataset); }
From source file:org.sonar.server.charts.deprecated.PieChart.java
private void configurePlot() { PiePlot plot = (PiePlot) jfreechart.getPlot(); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDataset(dataset); plot.setBackgroundAlpha(0.0f);/*www . ja va 2 s. co m*/ plot.setCircular(true); plot.setLabelGenerator(null); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setShadowPaint(null); plot.setLabelLinkMargin(0.0); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.10); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputPie.java
@Override protected void clearDataSet(final IScope scope) { // TODO Auto-generated method stub super.clearDataSet(scope); final PiePlot plot = (PiePlot) this.chart.getPlot(); jfreedataset.clear();// w ww. j a v a 2 s .c o m jfreedataset.add(0, new DefaultPieDataset()); plot.setDataset((DefaultPieDataset) jfreedataset.get(0)); IdPosition.clear(); nbseries = 0; }
From source file:com.vectorprint.report.jfree.ChartBuilder.java
private void prepareChart(Dataset data, CHARTTYPE type) throws VectorPrintException { switch (type) { case AREA://from w w w .j ava2 s . co m chart = ChartFactory.createAreaChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); case LINE: if (chart == null) { chart = ChartFactory.createLineChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case LINE3D: if (chart == null) { chart = ChartFactory.createLineChart3D(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case BAR: if (chart == null) { chart = ChartFactory.createBarChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } case BAR3D: if (chart == null) { chart = ChartFactory.createBarChart3D(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } if (data instanceof CategoryDataset) { CategoryDataset cd = (CategoryDataset) data; chart.getCategoryPlot().setDataset(cd); } else { throw new VectorPrintException("you should use CategoryDataset for this chart"); } break; case PIE: chart = ChartFactory.createPieChart(title, null, legend, tooltips, urls); case PIE3D: if (chart == null) { chart = ChartFactory.createPieChart3D(title, null, legend, tooltips, urls); } if (data instanceof PieDataset) { PieDataset pd = (PieDataset) data; PiePlot pp = (PiePlot) chart.getPlot(); pp.setDataset(pd); } else { throw new VectorPrintException("you should use PieDataset for this chart"); } break; case XYLINE: chart = ChartFactory.createXYLineChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); case XYAREA: if (chart == null) { chart = ChartFactory.createXYAreaChart(title, categoryLabel, valueLabel, null, getOrientation(), legend, tooltips, urls); } if (data instanceof XYDataset) { XYDataset xy = (XYDataset) data; chart.getXYPlot().setDataset(xy); } else { throw new VectorPrintException("you should use XYDataset for this chart"); } break; case TIME: chart = ChartFactory.createTimeSeriesChart(title, categoryLabel, valueLabel, null, legend, tooltips, urls); if (data instanceof TimeSeriesCollection) { TimeSeriesCollection xy = (TimeSeriesCollection) data; chart.getXYPlot().setDataset(xy); } else { throw new VectorPrintException("you should use TimeSeriesCollection for this chart"); } break; default: throw new VectorPrintException("unsupported chart"); } chart.setAntiAlias(true); chart.setTextAntiAlias(true); }
From source file:org.hxzon.demo.jfreechart.PieDatasetDemo2.java
private static JFreeChart createPieChart(PieDataset dataset, PieDataset previousDataset) { final boolean greenForIncrease = true; final boolean subTitle = true; final boolean showDifference = true; int percentDiffForMaxScale = 20; 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 w w .j av a2s . com*/ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } @SuppressWarnings({ "rawtypes", "unchecked" }) List<Comparable> keys = dataset.getKeys(); DefaultPieDataset series = null; if (showDifference) { series = new DefaultPieDataset(); } double colorPerPercent = 255.0 / percentDiffForMaxScale; for (@SuppressWarnings("rawtypes") Comparable key : keys) { Number newValue = dataset.getValue(key); Number oldValue = previousDataset.getValue(key); if (oldValue == null) { if (greenForIncrease) { plot.setSectionPaint(key, Color.green); } else { plot.setSectionPaint(key, Color.red); } if (showDifference) { series.setValue(key + " (+100%)", newValue); } } else { double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0; double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 : Math.abs(percentChange) * colorPerPercent); if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue() || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); } else { plot.setSectionPaint(key, new Color((int) shade, 0, 0)); } if (showDifference) { series.setValue( key + " (" + (percentChange >= 0 ? "+" : "") + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")", newValue); } } } if (showDifference) { plot.setDataset(series); } JFreeChart chart = new JFreeChart("Pie Chart Demo 2", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); if (subTitle) { TextTitle subtitle = null; subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } plot.setNoDataMessage("No data available"); return chart; }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void chartMouseClicked(ChartMouseEvent chartMouseEvent) { ChartEntity entity = chartMouseEvent.getEntity(); MouseEvent mouseEvent = chartMouseEvent.getTrigger(); if (SwingUtilities.isLeftMouseButton(mouseEvent) && entity != null && entity instanceof PieSectionEntity) { java.util.List<String> names = dataset.getTransactionTypeNames(); PieSectionEntity pieSectionEntity = (PieSectionEntity) entity; int idx = pieSectionEntity.getSectionIndex(); String name = (String) JOptionPane.showInputDialog(null, "Enter the name for this transaction type", "Transaction Type", JOptionPane.PLAIN_MESSAGE, null, null, ""); if (name != null) { if (names.contains(name) && !names.get(idx).equals(name) && !name.isEmpty()) { JOptionPane.showMessageDialog(null, "Please enter a different name for the transaction type.\nEach name has to be unique.", "Warning", JOptionPane.WARNING_MESSAGE); } else { PieDataset oldDataset = pieSectionEntity.getDataset(); DefaultPieDataset newDataset = new DefaultPieDataset(); PiePlot plot = (PiePlot) chart.getPlot(); String oldName = (String) oldDataset.getKey(idx); names.set(idx, name);// w w w.j a va2 s . c om dataset.setTransactionTypeName(idx, name); for (int i = 0; i < oldDataset.getItemCount(); ++i) { String key = (String) oldDataset.getKey(i); Number number = oldDataset.getValue(i); if (key.equals(oldName)) { if (name.isEmpty()) newDataset.setValue("Transaction Type " + (i + 1), number); else newDataset.setValue(name, number); } else { newDataset.setValue(key, number); } } Paint[] tempPaint = new Paint[oldDataset.getItemCount()]; for (int i = 0; i < oldDataset.getItemCount(); ++i) { String key = (String) oldDataset.getKey(i); tempPaint[i] = plot.getSectionPaint(key); } ((DefaultPieDataset) oldDataset).clear(); plot.setDataset(newDataset); for (int i = 0; i < newDataset.getItemCount(); ++i) { String key = (String) newDataset.getKey(i); plot.setSectionPaint(key, tempPaint[i]); } } } } }