List of usage examples for org.jfree.chart.plot PiePlot3D setNoDataMessage
public void setNoDataMessage(String message)
null
, and sends a PlotChangeEvent to all registered listeners. From source file:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java
/** * Cre le graphe JFreeChart./*ww w . ja v a 2s . c o m*/ * * @param piedataset * : la source de donnes afficher * @return le diagramme */ private JFreeChart createChart(final GraphPieDataset piedataset) { final JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); final PiePlot3D pieplot3d = (PiePlot3D) 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.setBackgroundAlpha(0.0F); pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay); 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:org.sonar.plugins.abacus.chart.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*from w ww . ja va2 s. c om*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(360); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.WHITE); plot.setDarkerSides(false); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.15); return plot; }
From source file:org.sonar.plugins.scmstats.charts.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*from w ww. ja v a2 s. c om*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(180); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.GREEN); plot.setDarkerSides(true); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.GRAY); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.01); plot.setMaximumLabelWidth(0.25); return plot; }
From source file:com.pureinfo.srm.reports.impl.PieChartBuilder.java
/** * @throws PureException/*from w ww . ja va 2 s . c o 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; }
From source file:com.tonbeller.jpivot.chart.ChartComponent.java
/** * Entry point for producing charts, called by wcf render tag. * Produces a jfreechart dataset from olap model, then creates a chart and * writes it to the servlet container temp directory. * Returns a DOM document for Renderer to transform into html. * Requires that jfreechart servlet is installed in this application context. *///from w ww .j a va 2 s . com public Document render(RequestContext context) throws Exception { // check if we need to produce a new chart if (dirty) { // clear old listeners dispatcher.clear(); this.result = olapModel.getResult(); this.cellIterator = result.getCells().iterator(); this.dimCount = result.getAxes().length; DefaultCategoryDataset dataset = null; switch (dimCount) { case 1: logger.info("1-dim data"); dataset = build1dimDataset(); break; case 2: logger.info("2-dim data"); dataset = build2dimDataset(); break; default: logger.error("less than 1 or more than 2 dimensions"); throw new IllegalArgumentException("ChartRenderer requires a 1 or 2 dimensional result"); } // re-set dirty flag dirty = false; // create font titleFont = new java.awt.Font(fontName, fontStyle, fontSize); CategoryURLGenerator urlGenerator = new jpivotCategoryURLGenerator(webControllerURL); // Create the chart object JFreeChart chart = null; switch (chartType) { case 1: chart = ChartFactory.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 2: chart = ChartFactory.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 3: chart = ChartFactory.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 4: chart = ChartFactory.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 5: chart = ChartFactory.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 6: chart = ChartFactory.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 7: chart = ChartFactory.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 8: chart = ChartFactory.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 9: chart = ChartFactory.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 10: chart = ChartFactory.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 11: chart = ChartFactory.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 12: chart = ChartFactory.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 13: chart = ChartFactory.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 14: chart = ChartFactory.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case 15: chart = ChartFactory.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_COLUMN, dataset, webControllerURL)); break; case 16: chart = ChartFactory.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL)); break; case 17: chart = ChartFactory.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_COLUMN, dataset, webControllerURL)); break; case 18: chart = ChartFactory.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, new jpivotPieURLGenerator(TableOrder.BY_ROW, dataset, webControllerURL)); break; default: throw new Exception("An unknown Chart Type was requested"); } try { chart.setBackgroundPaint(new java.awt.Color(bgColorR, bgColorG, bgColorB)); java.awt.Font slicerFont = new java.awt.Font(slicerFontName, slicerFontStyle, slicerFontSize); java.awt.Font axisFont = new java.awt.Font(axisFontName, axisFontStyle, axisFontSize); java.awt.Font axisTickFont = new java.awt.Font(axisTickFontName, axisTickFontStyle, axisTickFontSize); java.awt.Font legendFont = new java.awt.Font(legendFontName, legendFontStyle, legendFontSize); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot catPlot = (CategoryPlot) plot; catPlot.getDomainAxis().setLabelFont(axisFont); catPlot.getRangeAxis().setLabelFont(axisFont); catPlot.getDomainAxis().setTickLabelFont(axisTickFont); catPlot.getRangeAxis().setTickLabelFont(axisTickFont); catPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(100.0f); double angle = -2.0 * Math.PI / 360.0 * (double) tickLabelRotate; CategoryLabelPositions oldp = catPlot.getDomainAxis().getCategoryLabelPositions(); CategoryLabelPositions newp = new CategoryLabelPositions( oldp.getLabelPosition(RectangleEdge.TOP), new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.0f), oldp.getLabelPosition(RectangleEdge.LEFT), oldp.getLabelPosition(RectangleEdge.RIGHT)); catPlot.getDomainAxis().setCategoryLabelPositions(newp); } else if (plot instanceof PiePlot3D) { PiePlot3D piePlot = (PiePlot3D) plot; //piePlot.setSectionLabelFont(axisFont); piePlot.setLabelFont(axisFont); //piePlot.setSeriesLabelFont(axisTickFont); //piePlot.setSectionLabelType(piePlot.NO_LABELS); piePlot.setDirection(org.jfree.util.Rotation.CLOCKWISE); piePlot.setForegroundAlpha(0.5f); piePlot.setNoDataMessage("No data to display"); } else if (plot instanceof PiePlot) { PiePlot piePlot = (PiePlot) plot; //piePlot.setSectionLabelFont(axisFont); //piePlot.setSeriesLabelFont(axisTickFont); piePlot.setLabelFont(axisFont); //piePlot.setSectionLabelType(piePlot.NO_LABELS); } LegendTitle legend = (LegendTitle) chart.getLegend(); if (legend != null) { legend.setItemFont(legendFont); /* RectangleAnchor legendRectAnchor=RectangleAnchor.BOTTOM; switch (legendPosition){ case 0: legendRectAnchor = RectangleAnchor.LEFT; break; case 1: legendRectAnchor = RectangleAnchor.TOP; break; case 2: legendRectAnchor = RectangleAnchor.RIGHT; break; case 3: legendRectAnchor = RectangleAnchor.BOTTOM; break; } legend.setLegendItemGraphicAnchor(legendRectAnchor); */ RectangleEdge legendRectEdge = RectangleEdge.BOTTOM; switch (legendPosition) { case 0: legendRectEdge = RectangleEdge.LEFT; break; case 1: legendRectEdge = RectangleEdge.TOP; break; case 2: legendRectEdge = RectangleEdge.RIGHT; break; case 3: legendRectEdge = RectangleEdge.BOTTOM; break; } legend.setPosition(legendRectEdge); } if (showSlicer) { RectangleEdge slicerRectPos = RectangleEdge.BOTTOM; HorizontalAlignment slicerHorizAlignment = HorizontalAlignment.LEFT; switch (slicerPosition) { case 0: slicerRectPos = RectangleEdge.TOP; break; case 1: slicerRectPos = RectangleEdge.BOTTOM; break; case 2: slicerRectPos = RectangleEdge.RIGHT; break; case 3: slicerRectPos = RectangleEdge.LEFT; break; } switch (slicerAlignment) { case 4: slicerHorizAlignment = HorizontalAlignment.CENTER; break; case 3: slicerHorizAlignment = HorizontalAlignment.LEFT; break; case 2: slicerHorizAlignment = HorizontalAlignment.RIGHT; break; } TextTitle slicer = new TextTitle(buildSlicer(), slicerFont, Color.BLACK, slicerRectPos, slicerHorizAlignment, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); slicer.setPosition(slicerRectPos); chart.addSubtitle(slicer); } info = new ChartRenderingInfo(new StandardEntityCollection()); // Write the chart image to the temporary directory HttpSession session = context.getSession(); filename = ServletUtilities.saveChartAsPNG(chart, chartWidth, chartHeight, info, session); } catch (Exception e) { filename = "public_error_500x300.png"; dirty = true; } } // new DOM document DocumentBuilder parser = XmlUtils.getParser(); // get an image map for the chart, wrap it in xchart tags String xchart = "<xchart>" + writeImageMap(filename, info, false) + "</xchart>"; /* if (logger.isDebugEnabled()) { logger.debug("Chart XML"); logger.debug(xchart); } */ // create an InputStream from the DOM document InputStream stream = new ByteArrayInputStream(xchart.getBytes("UTF-8")); document = parser.parse(stream); Element root = document.getDocumentElement(); // create url for img tag String graphURL = getGraphURL(context); Element img = document.createElement("img"); img.setAttribute("src", graphURL); img.setAttribute("width", new Integer(chartWidth).toString()); img.setAttribute("height", new Integer(chartHeight).toString()); img.setAttribute("style", "border:0;"); img.setAttribute("usemap", "#" + filename); root.appendChild(img); return document; }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createPieChart(String titleLabel, PieDataset dataset) { // System.out.println("rotation="+rotation); if (dimension.equalsIgnoreCase("3D")) { JFreeChart chart = ChartFactory.createPieChart3D(titleLabel, // chart title dataset, // data true, // include legend true, false);//from w ww . j a v a 2s . com PiePlot3D plot = (PiePlot3D) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart; } //end of 3D //2D ring if (rotation.equalsIgnoreCase("ring")) { JFreeChart chart = ChartFactory.createRingChart(titleLabel, // chart title dataset, // data false, // include legend true, false); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } //2D JFreeChart chart = ChartFactory.createPieChart(titleLabel, // chart title dataset, // data true, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }