PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(Color.WHITE); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setStartAngle(290); plot.setShadowXOffset(0.0); plot.setShadowYOffset(0.0); plot.setBaseSectionOutlinePaint(ChartDefaults.outlinePaintColor); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} {1} ({2})")); plot.setSectionPaint(dataset.getKey(j), ChartDefaults.darkColors[j]); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1}")); plot.setLabelGap(0.04); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.gray.brighter()); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelFont(ChartDefaults.defaultFont); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1} - {2})")); plot.setLegendItemShape(new Rectangle(0, 0, 10, 10));
PiePlot plot = (PiePlot) someChart.getPlot(); plot.setSectionPaint(KEY1, Color.green); plot.setSectionPaint(KEY2, Color.red); plot.setExplodePercent(KEY1, 0.10); plot.setSimpleLabels(true); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator( "{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); plot.setLabelGenerator(gen);
/** * Sets the paint used to fill a section of the pie and sends a * {@link PlotChangeEvent} to all registered listeners. * * @param section the section index (zero-based). * @param paint the paint (<code>null</code> permitted). * * @deprecated Use {@link #setSectionPaint(Comparable, Paint)} instead. */ public void setSectionPaint(int section, Paint paint) { Comparable key = getSectionKey(section); setSectionPaint(key, paint); }
PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelBackgroundPaint(null); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null);
if (displayCols > displayRows && area.getWidth() < area.getHeight()) { int temp = displayCols; displayCols = displayRows; int x = (int) area.getX(); int y = (int) area.getY(); int width = ((int) area.getWidth()) / displayCols; title = this.dataset.getColumnKey(pieIndex).toString(); this.pieChart.setTitle(title); piedataset = dd; PiePlot piePlot = (PiePlot) this.pieChart.getPlot(); piePlot.setDataset(piedataset); piePlot.setPieIndex(pieIndex); p = (Paint) this.sectionPaints.get(key); piePlot.setSectionPaint(key, p); subinfo = new ChartRenderingInfo(); this.pieChart.draw(g2, rect, subinfo); if (info != null) { assert subinfo != null;
plot.setOutlineStroke(null); JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); pieChart.setTitle(seriesTitle); pieChart.removeLegend(); pieChart.setBackgroundPaint(null); plot.setPieChart(pieChart); = new StandardPieToolTipGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setToolTipGenerator(tooltipGenerator); PieURLGenerator urlGenerator = new StandardPieURLGenerator(); PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); pp.setURLGenerator(urlGenerator);
CategoryPlot plot = chart.getCategoryPlot(); XYPlot plot = chart.getXYPlot(); PiePlot piePlot = ((PiePlot) chart.getPlot()); piePlot.setCircular(true); piePlot.setLabelGenerator(null); piePlot.setShadowXOffset(0); piePlot.setShadowYOffset(0); piePlot.setSectionPaint(sparklineDataset.getData().get(i).getSeriesLabel(), sparklineDataset.getData().get(i).getSeriesColor());
chart.setAntiAlias(isAntiAlias()); chart.setBorderVisible(isBorderVisible()); chart.setBorderPaint(Color.lightGray); PieURLGenerator urlGenerator = new ChartPieUrlGenerator(urlExpression); plot.setURLGenerator(urlGenerator); } else { plot.setURLGenerator(null); plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); plot.setLabelGap(0.03); plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setCircular(true); plot.setBaseSectionOutlinePaint(Color.BLACK); new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier);
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; }
public static void applyStyles(final JFreeChart chart) { final TextTitle title = chart.getTitle(); if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); for (int i = 0; i < chart.getSubtitleCount(); i++) { final Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); 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); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); piePlot.setDrawingSupplier(new DCDrawingSupplier());
boolean urls, boolean subTitle, boolean showDifference) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); plot.setToolTipGenerator(new StandardPieToolTipGenerator()); plot.setURLGenerator(new StandardPieURLGenerator()); plot.setSectionPaint(key, Color.GREEN); plot.setSectionPaint(key, Color.RED); || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) { plot.setSectionPaint(key, new Color(0, (int) shade, 0)); plot.setSectionPaint(key, new Color((int) shade, 0, 0)); plot.setDataset(series); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + "=change >=+" + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle);
plot = ((PiePlot) chart.getPlot()); ((PiePlot) plot).setCircular(true); ((PiePlot) plot).setLabelGenerator(null); ((PiePlot) plot).setShadowXOffset(0); ((PiePlot) plot).setShadowYOffset(0); ((PiePlot) plot).setSectionOutlinesVisible(false); ((PiePlot) plot).setSectionPaint("A", labelA); ((PiePlot) plot).setSectionPaint("B", labelB); ((PiePlot) plot).setSectionPaint("C", labelC); ((PiePlot) plot).setSectionPaint("D", labelD); chart.getPlot().setOutlineVisible(false); JFreeChart tempChart = new JFreeChart(null, plot); tempChart.removeLegend(); tempChart.setBackgroundPaint(Color.white);
/** * 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; }
else chart = ChartFactory.createPieChart(null, dataset, false, false, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setStartAngle(150D); plot.setForegroundAlpha(transparency); chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor())); plot.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor())); chart.setPadding(new RectangleInsets(5,5,5,5)); plot.setInsets(new RectangleInsets(1,1,1,1)); plot.setOutlinePaint(null); chart.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc"));
Plot plot = (Plot) jfchart.getPlot(); float alpha = (float)(((float)chart.getFgAlpha()) / 255); plot.setForegroundAlpha(alpha); jfchart.setBackgroundPaint(new Color(paneRGB[0], paneRGB[1], paneRGB[2], chart.getPaneAlpha())); jfchart.getTitle().setFont(tfont); pplot.setLabelFont(xlbfont);
public static ChartHelper generatePieChart(PieDataset dataset, String chartTitle, Color[][] colorScheme) { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createPieChart(chartTitle, dataset, legend, tooltips, urls); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(false); PiePlot plot = (PiePlot) chart.getPlot(); // Make section labels in the format "<Key>" plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); plot.setBackgroundPaint(Color.white); plot.setOutlinePaint(null); for(int i = 0; i < colorScheme.length; i++) { setSectionColor(dataset, plot, i, colorScheme[i][0], colorScheme[i][1]); } plot.setShadowXOffset(0); plot.setShadowYOffset(0); return new ChartHelper(chart); }
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.setLabelGap(0.02); chart.setBackgroundPaint(java.awt.Color.white); chart.setTitle(new TextTitle(plotTitle, new Font("SansSerif", Font.BOLD, 12)));
JFreeChart chart = ChartFactory.createPieChart(null, dataset, false, false, false); chart.setBackgroundPaint(Color.white); final PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE ); plot.setDrawingSupplier(ds); plot.setLabelGenerator(new StandardPieSectionLabelGenerator( "{0} = {1} ({2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance() )); plot.setNoDataMessage(Messages.Dashboard_NoDataAvailable());
/** * Creates a pie chart with default settings. * <P> * The chart object returned by this method uses a {@link PiePlot} instance * as the plot. * * @param title the chart title ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param locale the locale ({@code null} not permitted). * * @return A pie chart. * * @since 1.0.7 */ public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips, Locale locale) { PiePlot plot = new PiePlot(dataset); plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
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; }