List of usage examples for org.jfree.chart.plot PiePlot setDirection
public void setDirection(Rotation direction)
From source file:net.sf.eclipsecs.ui.stats.views.GraphStatsView.java
/** * Cre le graphe JFreeChart./*ww w .j ava 2 s .c om*/ * * @param piedataset * : la source de donnes afficher * @return le diagramme */ private JFreeChart createChart(GraphPieDataset piedataset) { JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); PiePlot pieplot3d = (PiePlot) jfreechart.getPlot(); pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0)); final double angle = 290D; pieplot3d.setStartAngle(angle); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foreground = 0.5F; pieplot3d.setForegroundAlpha(foreground); pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay); pieplot3d.setCircular(true); pieplot3d.setOutlinePaint(null); pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); pieplot3d.setLabelGap(0.02); pieplot3d.setLabelOutlinePaint(null); pieplot3d.setLabelShadowPaint(null); pieplot3d.setLabelBackgroundPaint(Color.WHITE); pieplot3d.setBackgroundPaint(Color.WHITE); pieplot3d.setInteriorGap(0.02); pieplot3d.setMaximumLabelWidth(0.20); return jfreechart; }
From source file:com.jd.survey.web.statistics.StatisticsController.java
@Secured({ "ROLE_ADMIN", "ROLE_SURVEY_ADMIN" }) private JFreeChart createChart(PieDataset pieDataset, String title) { try {/*from w w w . j av a 2 s.c om*/ 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)); } }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.SimplePie.java
public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); JFreeChart chart = null;//from ww w. ja v a2 s .c o m if (!threeD) { chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data legend, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } else { chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data true, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(1.0f); plot.setDepthFactor(0.2); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); // plot.setNoDataMessages("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Creates a Pie Chart based on map.//from w w w . jav a2 s .com * * @return the Pie Chart generated. */ public JFreeChart getPieChart(Map<String, Double> pieValues) { DefaultPieDataset dataset = new DefaultPieDataset(); for (String key : pieValues.keySet()) { dataset.setValue(key, pieValues.get(key)); } JFreeChart chart = ChartFactory.createPieChart3D(null, // chart title dataset, // data true, // include legend true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(false); chart.setBorderPaint(null); PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(true); plot.setLabelGap(0.02); plot.setOutlinePaint(null); plot.setLabelLinksVisible(false); plot.setLabelGenerator(null); plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); plot.setStartAngle(270); plot.setDirection(Rotation.ANTICLOCKWISE); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.33); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.piecharts.LinkablePie.java
public JFreeChart createChart(DatasetMap datasets) { Dataset dataset = (Dataset) datasets.getDatasets().get("1"); boolean document_composition = false; if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION)) document_composition = true;//from w ww .j a v a 2s. c o m JFreeChart chart = null; if (!threeD) { chart = ChartFactory.createPieChart(name, (PieDataset) dataset, // data legend, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); } else { chart = ChartFactory.createPieChart3D(name, (PieDataset) dataset, // data true, // include legend true, false); chart.setBackgroundPaint(color); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(true); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(1.0f); plot.setDepthFactor(0.2); plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); plot.setCircular(false); plot.setLabelGap(0.02); plot.setNoDataMessage("No data available"); //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer); MyPieUrlGenerator pieUrl = new MyPieUrlGenerator(rootUrl); pieUrl.setDocument_composition(document_composition); pieUrl.setCategoryUrlLabel(categoryUrlName); pieUrl.setDrillDocTitle(drillDocTitle); pieUrl.setTarget(target); plot.setURLGenerator(pieUrl); if (percentage == false) { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})")); } else { plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); } } TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }