plot.setLabelGenerator(null); } else { plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available");
public JFreeChart createPieChart(String title, PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage("No data to display"); StandardPieSectionLabelGenerator labelGenerator = new StandardPieSectionLabelGenerator("{0} {1} ({2})"); plot.setLabelGenerator(labelGenerator); plot.setInteriorGap(0.01); plot.setMaximumLabelWidth(0.32); Font font = new Font(chart.getLegend().getItemFont().getFamily(), Font.PLAIN, 12); plot.setLabelFont(font); plot.setLabelBackgroundPaint(new Color(220, 220, 220)); font = new Font(chart.getLegend().getItemFont().getFamily(), Font.PLAIN, 12); chart.getLegend().setItemFont(font); return chart; }
/** * Applies the attributes of this theme to a {@link PiePlot} instance. * This method also clears any set values for the section paint, outline * etc, so that the theme's {@link DrawingSupplier} will be used. * * @param plot the plot (<code>null</code> not permitted). */ protected void applyToPiePlot(PiePlot plot) { plot.setLabelLinkPaint(this.labelLinkPaint); plot.setLabelLinkStyle(this.labelLinkStyle); plot.setLabelFont(this.regularFont); // clear the section attributes so that the theme's DrawingSupplier // will be used if (plot.getAutoPopulateSectionPaint()) { plot.clearSectionPaints(false); } if (plot.getAutoPopulateSectionOutlinePaint()) { plot.clearSectionOutlinePaints(false); } if (plot.getAutoPopulateSectionOutlineStroke()) { plot.clearSectionOutlineStrokes(false); } }
plot.setLabelGenerator( new GPieSectionLabelGenerator(labels)); plot.setLabelFont(font); plot.setLabelPaint(Color.gray);
/** * Applies the attributes of this theme to a {@link PiePlot} instance. * This method also clears any set values for the section paint, outline * etc, so that the theme's {@link DrawingSupplier} will be used. * * @param plot the plot ({@code null} not permitted). */ protected void applyToPiePlot(PiePlot plot) { plot.setLabelLinkPaint(this.labelLinkPaint); plot.setLabelLinkStyle(this.labelLinkStyle); plot.setLabelFont(this.regularFont); plot.setShadowGenerator(this.shadowGenerator); // clear the section attributes so that the theme's DrawingSupplier // will be used if (plot.getAutoPopulateSectionPaint()) { plot.clearSectionPaints(false); } if (plot.getAutoPopulateSectionOutlinePaint()) { plot.clearSectionOutlinePaints(false); } if (plot.getAutoPopulateSectionOutlineStroke()) { plot.clearSectionOutlineStrokes(false); } }
/** * Creates a pie chart. * * @return A pie chart. */ private static JFreeChart createPieChart() { JFreeChart chart = ChartFactory.createPieChart(null, null, false, true, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setInteriorGap(0.06); plot.setStartAngle(0.0); plot.setLabelGenerator(null); plot.setBaseSectionOutlinePaint(Color.white); plot.setBaseSectionOutlineStroke(new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setLabelPadding(RectangleInsets.ZERO_INSETS); plot.setLabelFont(new Font("Dialog", Font.PLAIN, 12)); plot.setLabelPaint(Color.gray); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{2}")); return chart; }
plot.setLabelOutlinePaint(Color.gray.brighter()); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelFont(ChartDefaults.defaultFont);
plot.setLabelOutlinePaint(Color.gray.brighter()); plot.setLabelShadowPaint(ChartDefaults.transparent); plot.setLabelFont(ChartDefaults.defaultFont);
piePlot.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale())); piePlot.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
private JFreeChart getMultiplePieChart( BaseChart chart, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW, !chart.isHideLegend(), false, false ); setBasicConfig( multiplePieChart, chart ); if ( multiplePieChart.getLegend() != null ) { multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT ); } MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot(); JFreeChart pieChart = multiplePiePlot.getPieChart(); pieChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); pieChart.getTitle().setFont( SUB_TITLE_FONT ); PiePlot piePlot = (PiePlot) pieChart.getPlot(); piePlot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setLabelFont( LABEL_FONT ); piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) ); piePlot.setSimpleLabels( true ); piePlot.setIgnoreZeroValues( true ); piePlot.setIgnoreNullValues( true ); piePlot.setShadowXOffset( 0d ); piePlot.setShadowYOffset( 0d ); for ( int i = 0; i < dataSets[0].getColumnCount(); i++ ) { piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] ); } return multiplePieChart; }
pplot.setLabelFont(xlbfont);
piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(STROKE_NORMAL);
pie.setInteriorGap( pieDefinition.getInteriorGap() ); pie.setStartAngle( pieDefinition.getStartAngle() ); pie.setLabelFont( pieDefinition.getLabelFont() ); if ( pieDefinition.getLabelPaint() != null ) { pie.setLabelPaint( pieDefinition.getLabelPaint() );