List of usage examples for org.jfree.chart.plot PiePlot3D setDepthFactor
public void setDepthFactor(double factor)
From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java
public static JFreeChart createChartWithPieDataSet(ChartData chartData) { PieDataset dataset = (PieDataset) chartData.getDatasource(); String type = chartData.getType(); boolean legend = chartData.isLegend(); JFreeChart chart = null;//from www. j a v a 2 s. c om if (type.equalsIgnoreCase("pie")) { if (chartData.isChart3d()) { chart = ChartFactory.createPieChart3D("", dataset, legend, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDepthFactor((float) chartData.getDepth() / 100); } else { chart = ChartFactory.createPieChart("", dataset, legend, true, false); } } else if (type.equalsIgnoreCase("ring")) { chart = ChartFactory.createRingChart("", dataset, legend, true, false); } PiePlot plot = (PiePlot) chart.getPlot(); plot.setStartAngle((float) chartData.getStartAngle()); if (chartData.getGenerateMap() != null) plot.setURLGenerator(new StandardPieURLGenerator("")); setPieSectionColors(chart, chartData); return chart; }
From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForDiskUsage.java
/** * This method generates JFreeChart instance for 3D Pie chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *//*from w w w . j a v a 2s . co m*/ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { boolean xFlag = false; ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean, reportColumnBeanX = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultPieDataset dataset = new DefaultPieDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis // String xColumnDBname = reportColumnBeanX.getDbColumnName(); if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); rsw.beforeFirst(); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnName = reportColumnBean.getColumnName(); if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } String xData = null; while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) { xData = "N/A"; } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING && xData.indexOf(':') != -1) { String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt( rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':')))); xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'), xData.length()); } dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName()))); } chart = ChartFactory.createPieChart3D("", // chart title dataset, // data true, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setBackgroundAlpha(0.0f); plot.setSectionOutlinesVisible(false); plot.setOutlineVisible(false); plot.setStartAngle(290); plot.setDepthFactor(0.1); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage("No data to display"); plot.setSectionOutlinesVisible(false); plot.setSectionOutlinePaint(Color.white); plot.setOutlineVisible(false); plot.setExplodePercent(dataset.getKey(0), 0.3); plot.setLabelLinkPaint(Color.gray); plot.setLabelBackgroundPaint(Color.white); plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); plot.setLabelOutlinePaint(Color.white); plot.setLabelShadowPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10)); legend.setMargin(0, 0, 2, 0); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})")); //Setting Color try { plot.setSectionPaint(dataset.getKey(0), new Color(0, 0, 254)); plot.setSectionPaint(dataset.getKey(1), new Color(255, 0, 254)); plot.setSectionPaint(dataset.getKey(2), new Color(176, 176, 255)); plot.setSectionPaint(dataset.getKey(3), new Color(255, 170, 255)); plot.setSectionPaint(dataset.getKey(4), new Color(69, 153, 204)); } catch (Exception e) { } } catch (Exception e) { CyberoamLogger.appLog.debug("Pie3D.e:" + e, e); } return chart; }
From source file:org.cyberoam.iview.charts.CustomToolTipGeneratorForPie3D.java
/** * This method generates JFreeChart instance for 3D Pie chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from uri. * @return jfreechart instance with iView Customization. *//* ww w . j av a2 s . com*/ public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { boolean xFlag = false; ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean, reportColumnBeanX = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; DefaultPieDataset dataset = new DefaultPieDataset(); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis // String xColumnDBname = reportColumnBeanX.getDbColumnName(); if (reportColumnBeanX.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); rsw.beforeFirst(); reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnName = reportColumnBean.getColumnName(); if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } String xData = null; while (rsw.next()) { xData = rsw.getString(reportColumnBeanX.getDbColumnName()); if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData)) { xData = "N/A"; } else if (reportColumnBeanX.getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING && xData.indexOf(':') != -1) { String data = data = ProtocolBean.getProtocolNameById(Integer.parseInt( rsw.getString(reportColumnBeanX.getDbColumnName()).substring(0, xData.indexOf(':')))); xData = data + rsw.getString(reportColumnBeanX.getDbColumnName()).substring(xData.indexOf(':'), xData.length()); } dataset.setValue(xData, new Long(rsw.getLong(reportColumnBean.getDbColumnName()))); } chart = ChartFactory.createPieChart3D("", // chart title dataset, // data true, // include legend true, // tooltips? false // URLs? ); /* *Setting additional customization to the chart. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setBackgroundAlpha(0.0f); plot.setSectionOutlinesVisible(false); plot.setOutlineVisible(false); plot.setStartAngle(290); plot.setDepthFactor(0.1); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage("No data to display"); plot.setSectionOutlinesVisible(false); plot.setSectionOutlinePaint(Color.white); plot.setOutlineVisible(false); plot.setExplodePercent(dataset.getKey(0), 0.3); plot.setLabelLinkPaint(Color.gray); plot.setLabelBackgroundPaint(Color.white); plot.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10)); plot.setLabelOutlinePaint(Color.white); plot.setLabelShadowPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 10)); legend.setMargin(0, 0, 2, 0); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); plot.setToolTipGenerator(new CustomToolTipGeneratorForPie3D("{0}: ({1} " + yColumnName + ", {2})")); //Setting Color try { plot.setSectionPaint(dataset.getKey(0), Pie3D.pieSections[0]); plot.setSectionPaint(dataset.getKey(1), Pie3D.pieSections[1]); plot.setSectionPaint(dataset.getKey(2), Pie3D.pieSections[2]); plot.setSectionPaint(dataset.getKey(3), Pie3D.pieSections[3]); plot.setSectionPaint(dataset.getKey(4), Pie3D.pieSections[4]); } catch (Exception e) { } } catch (Exception e) { CyberoamLogger.appLog.debug("Pie3D.e:" + e, e); } return chart; }
From source file:Grafica.java
private void init() { panel = new JPanel(); getContentPane().add(panel);// ww w. ja v a 2 s .c o m // Fuente de Datos DefaultPieDataset defaultpiedataset = new DefaultPieDataset(); defaultpiedataset.setValue("Abiertas 81%", new Double(81D)); defaultpiedataset.setValue("Cerradas 19%", new Double(19D)); // defaultpiedataset.setValue("Hacking", new Double(19.5D)); // defaultpiedataset.setValue("SEO", new Double(30.5D)); // defaultpiedataset.setValue("Redes", new Double(2.0D)); // Creando el Grafico JFreeChart chart = ChartFactory.createPieChart3D("Informe De Asignacin De Clases", defaultpiedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); pieplot3d.setDepthFactor(0.5); pieplot3d.setStartAngle(290D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.5F); // Mostrar Grafico ChartPanel chartPanel = new ChartPanel(chart); panel.add(chartPanel); }
From source file:de.berlios.statcvs.xml.chart.AbstractPieChart.java
/** * @param filename/*w w w . j a va 2 s.c om*/ * @param title */ public AbstractPieChart(ReportSettings settings, String filename, String title) { super(settings, filename, title); dataset = new DefaultPieDataset(); JFreeChart chart = ChartFactory.createPieChart3D(settings.getProjectName(), // chart title dataset, // data true, // include legend true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(270); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); //plot.setDepthFactor(0.2); plot.setDepthFactor(0.01); setChart(chart); }
From source file:Interfaz.VnReporteCliente.java
/** * Creates new form VnReporteCliente// w w w .ja va 2s . co m */ public VnReporteCliente() { initComponents(); setLocationRelativeTo(null); // Fuente de Datos defaultpiedataset = new DefaultPieDataset(); defaultpiedataset.setValue("Total de Tickets Liberados", (Integer.parseInt(lblNumTicketsResividos.getText()) - Integer.parseInt(lblNumTicketsSatisfactorios.getText()))); defaultpiedataset.setValue("Tickets Atendidos Satisfactoriamente", Integer.parseInt(lblNumTicketsSatisfactorios.getText())); //defaultpiedataset.setValue("Hacking", new Double(19.5D)); //defaultpiedataset.setValue("SEO", new Double(30.5D)); //defaultpiedataset.setValue("Redes", new Double(2.0D)); // Creando el Grafico chart = ChartFactory.createPieChart3D("Mi Proporcin", defaultpiedataset, true, true, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); pieplot3d.setDepthFactor(0.5); pieplot3d.setStartAngle(290D); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setForegroundAlpha(0.5F); // Mostrar Grafico chartPanel = new ChartPanel(chart); chartPanel.setBounds(0, 0, 314, 270); jpGrafico.add(chartPanel); }
From source file:biz.ixnay.pivot.charts.skin.jfree.PieChartViewSkin.java
@Override protected JFreeChart createChart() { PieChartView chartView = (PieChartView) getComponent(); String title = chartView.getTitle(); boolean showLegend = chartView.getShowLegend(); ChartView.CategorySequence categories = chartView.getCategories(); String seriesNameKey = chartView.getSeriesNameKey(); List<?> chartData = chartView.getChartData(); JFreeChart chart;/* w ww.j a v a 2 s. c om*/ if (threeDimensional) { if (chartData.getLength() > 1) { CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData); chart = ChartFactory.createMultiplePieChart3D(title, dataset, TableOrder.BY_ROW, showLegend, false, false); } else { PieSeriesDataset dataset = new PieSeriesDataset(categories, chartData.get(0)); chart = ChartFactory.createPieChart3D(title, dataset, showLegend, false, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setDarkerSides(darkerSides); plot.setDepthFactor(depthFactor); } } else { if (chartData.getLength() > 1) { CategorySeriesDataset dataset = new CategorySeriesDataset(categories, seriesNameKey, chartData); chart = ChartFactory.createMultiplePieChart(title, dataset, TableOrder.BY_ROW, showLegend, false, false); } else { PieSeriesDataset dataset = new PieSeriesDataset(categories, chartData.get(0)); chart = ChartFactory.createPieChart(title, dataset, showLegend, false, false); HashMap<String, String> categoryLabels = new HashMap<String, String>(); for (int i = 0, n = categories.getLength(); i < n; i++) { ChartView.Category category = categories.get(i); categoryLabels.put(category.getKey(), category.getLabel()); } PiePlot plot = (PiePlot) chart.getPlot(); for (String categoryKey : explodePercentages) { plot.setExplodePercent(categoryLabels.get(categoryKey), explodePercentages.get(categoryKey).doubleValue()); } } } return chart; }
From source file:bzstats.chart.KillRatioChart.java
/** * @see bzstats.chart.ChartFactory#getChart() *//*from w w w .j av a2s. c o m*/ protected JFreeChart getChart() { DefaultPieDataset dataset = new DefaultPieDataset(); Iterator playeriter = stats.getPlayerStats().values().iterator(); PlayerStats player; int playercount = 0; while (playeriter.hasNext() && (playercount++ < MAXPLAYERS)) { player = (PlayerStats) playeriter.next(); dataset.setValue(player.getName(), player.getKillRatio()); } // create chart and plot JFreeChart chart = ChartFactory.createPieChart3D("Killratio", // chart title dataset, // data false, // include legend true, false); chart.addSubtitle(new TextTitle("kills/deaths")); final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setBackgroundAlpha(0); plot.setNoDataMessage("No data to display"); plot.setDepthFactor(.1f); return chart; }
From source file:org.squale.squaleweb.util.graph.PieChartMaker.java
/** * Factorisation du code commun la gnration du graphe * //from ww w.jav a 2 s. co m * @param pRequest la requte * @return graphe de type Bubble */ private JFreeChart getCommonChart(HttpServletRequest pRequest) { JFreeChart chart = ChartFactory.createPieChart3D(mTitle, mDataSet, false, false, false); PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot(); final double startAngle = 290D; pieplot3d.setStartAngle(startAngle); final float depthFactor = 0.1f; pieplot3d.setDepthFactor(depthFactor); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foregroundAlpha = 0.5f; pieplot3d.setForegroundAlpha(foregroundAlpha); // Si on est en anglais, on laisse les nombre formates avec des "," pour sparer les milliers // Si on est en francais on remplace les "," par des points NumberFormat numberFormat = SqualeWebActionUtils.getNumberFormat(pRequest); // Pour le formatter de %, on laisse celui par dfaut pieplot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} loc ({2})", numberFormat, NumberFormat.getPercentInstance())); return chart; }
From source file:com.pureinfo.srm.reports.impl.PieChartBuilder.java
/** * @throws PureException/*from ww w . j a va 2 s . co m*/ * @see com.pureinfo.srm.reports.IChartBuilder#draw(java.util.List, int) */ public JFreeChart buildChart() { Iterator result = m_datas.iterator(); DefaultPieDataset ds = getDataset(result); JFreeChart jfreechart = ChartFactory.createPieChart3D(null, ds, false, false, false); jfreechart.setBackgroundPaint(Color.WHITE); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setOutlinePaint(Color.GRAY); pieplot3d.setOutlineStroke(new BasicStroke(1)); pieplot3d.setStartAngle(30D); pieplot3d.setDepthFactor(0.04); pieplot3d.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); pieplot3d.setCircular(false); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setOutlinePaint(Color.WHITE); pieplot3d.setInteriorGap(.15); Color color = new Color(0xaa, 0xaa, 0xaa, 255); pieplot3d.setBaseSectionOutlinePaint(color); pieplot3d.setBaseSectionOutlineStroke(new BasicStroke(0)); pieplot3d.setForegroundAlpha(0.6f); pieplot3d.setLabelLinkStroke(new BasicStroke(1)); pieplot3d.setLabelOutlinePaint(new Color(0x777777)); pieplot3d.setLabelBackgroundPaint(new Color(0xf1f1f7)); pieplot3d.setLabelLinkPaint(new Color(0xaa, 0xaa, 0xaa, 60)); pieplot3d.setNoDataMessage("No data to display"); pieplot3d.setLabelShadowPaint(new Color(0xdddddd)); pieplot3d.setLabelFont(new Font("", Font.PLAIN, 10)); if (m_nType == TYPE_PERCENT) { pieplot3d.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), PERCENT_NUMBER_FORMAT)); } fillChartInfo(ds); return jfreechart; }