private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart3D(title, // chart title dataset, // data true, // include legend true, true); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator( "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); return chart; }
@SuppressWarnings("deprecation") @Override public void customize(JFreeChart chart, JRChart jasperChart) { PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionPaint(4, new Color(0, 70, 120)); plot.setSectionPaint(3, new Color(0, 70, 120)); plot.setSectionPaint(2, new Color(189, 216, 77)); plot.setSectionPaint(1, new Color(253, 224, 94)); plot.setSectionPaint(0, new Color(219, 109, 29)); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0}: {1} ({2})"); plot.setLabelGenerator(generator); plot.setLabelBackgroundPaint(new Color(255,255,255)); Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 12); plot.setLabelFont(font); }
private void showVehicleInStore() { DefaultPieDataset dataset = new DefaultPieDataset(); List<Vehicle> vs = vehicleService.getAll(); for (Vehicle vehicle : vs) { if (vehicle.getQuantity() > 0) { dataset.setValue(vehicle.getModelNumber(), vehicle.getQuantity()); } } JFreeChart chart = ChartFactory.createPieChart3D("Vehicle In Store", // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator( "Model No {0} : {2}({1})", new DecimalFormat("0"), new DecimalFormat("0.00%")); plot.setLabelGenerator(generator); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); // we put the chart into a panel ChartPanel chartPanel = new ChartPanel(chart); changePanelReport(chartPanel); }
@Secured({"ROLE_ADMIN","ROLE_SURVEY_ADMIN"}) private JFreeChart createChart(PieDataset pieDataset, String title) { try{ JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, false,true,false); chart.setBackgroundPaint(null);//this line necessary for transparency of background final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setOpaque(false); //this line necessary for transparency of background chartPanel.setBackground(new Color(0, 0, 0, 0)); //this line necessary for transparency of background PiePlot plot = (PiePlot) chart.getPlot(); //Color[] colors = {new Color(170, 195, 217, 255),new Color(246, 140, 31, 255),new Color(204, 204, 204, 255),new Color(231, 238, 144, 255),new Color(51, 51, 51, 255),new Color(101, 125, 151, 255),new Color(0, 102, 255, 255)}; //PieRenderer renderer = new PieRenderer(colors); //renderer.setColor(plot, pieDataset); PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0}:{1}%"); plot.setLabelGenerator(generator); plot.setStartAngle(270); plot.setDirection(Rotation.CLOCKWISE); return chart; } catch (Exception e) { log.error(e.getMessage(),e); throw (new RuntimeException(e)); } }
/** * Sets the legend label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (<code>null</code> not permitted). * * @see #getLegendLabelGenerator() */ public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.legendLabelGenerator = generator; notifyListeners(new PlotChangeEvent(this)); }
/** * Sets the legend label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (<code>null</code> not permitted). * * @see #getLegendLabelGenerator() */ public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { if (generator == null) { throw new IllegalArgumentException("Null 'generator' argument."); } this.legendLabelGenerator = generator; fireChangeEvent(); }
/** * Returns the section label generator. * * @return The generator (possibly <code>null</code>). */ public PieSectionLabelGenerator getLabelGenerator() { return this.labelGenerator; }
/** * Sets the section label generator and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param generator the generator (<code>null</code> permitted). */ public void setLabelGenerator(PieSectionLabelGenerator generator) { this.labelGenerator = generator; notifyListeners(new PlotChangeEvent(this)); }
/** * Returns the section label generator. * * @return The generator (possibly <code>null</code>). * * @see #setLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLabelGenerator() { return this.labelGenerator; }
/** * Sets the section label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (<code>null</code> permitted). * * @see #getLabelGenerator() */ public void setLabelGenerator(PieSectionLabelGenerator generator) { this.labelGenerator = generator; notifyListeners(new PlotChangeEvent(this)); }
/** * Returns the legend label generator. * * @return The legend label generator (never <code>null</code>). * * @see #setLegendLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelGenerator() { return this.legendLabelGenerator; }
/** * Returns the legend label tool tip generator. * * @return The legend label tool tip generator (possibly <code>null</code>). * * @see #setLegendLabelToolTipGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelToolTipGenerator() { return this.legendLabelToolTipGenerator; }
/** * Sets the legend label tool tip generator and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (<code>null</code> permitted). * * @see #getLegendLabelToolTipGenerator() */ public void setLegendLabelToolTipGenerator( PieSectionLabelGenerator generator) { this.legendLabelToolTipGenerator = generator; notifyListeners(new PlotChangeEvent(this)); }
/** * Sets the section label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (<code>null</code> permitted). * * @see #getLabelGenerator() */ public void setLabelGenerator(PieSectionLabelGenerator generator) { this.labelGenerator = generator; fireChangeEvent(); }
/** * Sets the legend label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator (<code>null</code> not permitted). * * @see #getLegendLabelGenerator() */ public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { ParamChecks.nullNotPermitted(generator, "generator"); this.legendLabelGenerator = generator; fireChangeEvent(); }
/** * Sets the legend label tool tip generator and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator (<code>null</code> permitted). * * @see #getLegendLabelToolTipGenerator() */ public void setLegendLabelToolTipGenerator( PieSectionLabelGenerator generator) { this.legendLabelToolTipGenerator = generator; fireChangeEvent(); }
/** * Returns the section label generator. * * @return The generator (possibly {@code null}). * * @see #setLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLabelGenerator() { return this.labelGenerator; }
/** * Sets the section label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator ({@code null} permitted). * * @see #getLabelGenerator() */ public void setLabelGenerator(PieSectionLabelGenerator generator) { this.labelGenerator = generator; fireChangeEvent(); }
/** * Returns the legend label generator. * * @return The legend label generator (never {@code null}). * * @see #setLegendLabelGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelGenerator() { return this.legendLabelGenerator; }
/** * Sets the legend label generator and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param generator the generator ({@code null} not permitted). * * @see #getLegendLabelGenerator() */ public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { Args.nullNotPermitted(generator, "generator"); this.legendLabelGenerator = generator; fireChangeEvent(); }
/** * Returns the legend label tool tip generator. * * @return The legend label tool tip generator (possibly {@code null}). * * @see #setLegendLabelToolTipGenerator(PieSectionLabelGenerator) */ public PieSectionLabelGenerator getLegendLabelToolTipGenerator() { return this.legendLabelToolTipGenerator; }
/** * Sets the legend label tool tip generator and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param generator the generator ({@code null} permitted). * * @see #getLegendLabelToolTipGenerator() */ public void setLegendLabelToolTipGenerator( PieSectionLabelGenerator generator) { this.legendLabelToolTipGenerator = generator; fireChangeEvent(); }