List of usage examples for org.jfree.chart JFreeChart setBorderVisible
public void setBorderVisible(boolean visible)
From source file:com.marvelution.jira.plugins.hudson.charts.BuildTestResultsRatioChartGenerator.java
/** * {@inheritDoc}//from w w w. java2 s .c o m */ @Override public ChartHelper generateChart() { buildMap = new HashMap<Integer, Build>(); final CategoryTableXYDataset dataset = new CategoryTableXYDataset(); for (Build build : builds) { final TestResult results = build.getTestResult(); double percentagePass = 0.0D, percentageFail = 0.0D, percentageSkipped = 0.0D; if (results != null && results.getTotal() > 0) { percentagePass = Double.valueOf(results.getPassed()) / Double.valueOf(results.getTotal()) * 100.0D; percentageFail = Double.valueOf(results.getFailed()) / Double.valueOf(results.getTotal()) * 100.0D; percentageSkipped = Double.valueOf(results.getSkipped()) / Double.valueOf(results.getTotal()) * 100.0D; } dataset.add(Double.valueOf(build.getBuildNumber()), percentagePass, seriesNames[0]); dataset.add(Double.valueOf(build.getBuildNumber()), percentageFail, seriesNames[1]); dataset.add(Double.valueOf(build.getBuildNumber()), percentageSkipped, seriesNames[2]); buildMap.put(Integer.valueOf(build.getBuildNumber()), build); } final JFreeChart chart = ChartFactory.createStackedXYAreaChart("", "", getI18n().getText("hudson.charts.tests"), dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); XYPlot xyPlot = chart.getXYPlot(); xyPlot.setDataset(1, dataset); if (dataset.getItemCount() > 0) { XYLineAndShapeRenderer shapeRenderer = new XYLineAndShapeRenderer(false, true); shapeRenderer.setSeriesShapesVisible(1, false); shapeRenderer.setSeriesLinesVisible(1, false); shapeRenderer.setSeriesShapesVisible(2, false); shapeRenderer.setSeriesLinesVisible(2, false); shapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3.0D, -3.0D, 6.0D, 6.0D)); shapeRenderer.setSeriesPaint(0, GREEN_PAINT); shapeRenderer.setSeriesShapesFilled(0, true); shapeRenderer.setBaseToolTipGenerator(this); shapeRenderer.setBaseItemLabelFont(ChartDefaults.defaultFont); shapeRenderer.setBaseItemLabelsVisible(false); xyPlot.setRenderer(0, shapeRenderer); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); renderer.setSeriesPaint(0, GREEN_PAINT); renderer.setSeriesPaint(1, RED_PAINT); renderer.setSeriesPaint(2, YELLOW_PAINT); renderer.setBaseItemLabelFont(ChartDefaults.defaultFont); renderer.setBaseItemLabelsVisible(false); xyPlot.setRenderer(1, renderer); renderer.setBaseToolTipGenerator(this); } ValueAxis rangeAxis = xyPlot.getRangeAxis(); rangeAxis.setLowerBound(0.0D); rangeAxis.setUpperBound(100.0D); final NumberAxis domainAxis = new NumberAxis(); domainAxis.setLowerBound(Collections.min(buildMap.keySet())); domainAxis.setUpperBound(Collections.max(buildMap.keySet())); final TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); domainAxis.setStandardTickUnits(ticks); xyPlot.setDomainAxis(domainAxis); ChartUtil.setupPlot(xyPlot); return new ChartHelper(chart); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.targetcharts.WinLose.java
@Override public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); DefaultCategoryDataset dataset = (DefaultCategoryDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBarChart(name, null, null, dataset, PlotOrientation.VERTICAL, legend, false, false);//w w w .ja v a2 s . c o m chart.setBorderVisible(false); chart.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } CategoryPlot plot = chart.getCategoryPlot(); plot.setOutlineVisible(false); plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setBackgroundPaint(color); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.setRangeCrosshairPaint(color.BLACK); // customize axes CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); domainAxis.setCategoryMargin(0.2); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setVisible(false); rangeAxis.setRange(new Range(-(barHeight + 0.2), (barHeight + 0.2))); // customize renderer MyBarRendererThresholdPaint renderer = new MyBarRendererThresholdPaint(useTargets, thresholds, dataset, timeSeries, nullValues, bottomThreshold, color); if (wlt_mode.doubleValue() == 0) { renderer.setBaseItemLabelsVisible(Boolean.FALSE, true); } else { renderer.setBaseItemLabelsVisible(Boolean.TRUE, true); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}", new DecimalFormat("0.#")) { public String generateLabel(CategoryDataset dataset, int row, int column) { if (dataset.getValue(row, column) == null || dataset.getValue(row, column).doubleValue() == 0) return ""; String columnKey = (String) dataset.getColumnKey(column); int separator = columnKey.indexOf('-'); String month = columnKey.substring(0, separator); String year = columnKey.substring(separator + 1); int monthNum = Integer.parseInt(month); if (wlt_mode.doubleValue() >= 1 && wlt_mode.doubleValue() <= 4) { if (wlt_mode.doubleValue() == 2 && column % 2 == 0) return ""; Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, monthNum - 1); SimpleDateFormat dataFormat = new SimpleDateFormat("MMM"); return dataFormat.format(calendar.getTime()); } else return "" + monthNum; } }); } if (wlt_mode.doubleValue() == 3) { renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 2)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 2)); } else if (wlt_mode.doubleValue() == 4 || wlt_mode.doubleValue() == 5) { renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, org.jfree.ui.TextAnchor.BOTTOM_CENTER, org.jfree.ui.TextAnchor.BOTTOM_RIGHT, Math.PI / 4)); renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, org.jfree.ui.TextAnchor.TOP_CENTER, org.jfree.ui.TextAnchor.HALF_ASCENT_LEFT, Math.PI / 4)); } if (legend == true) { LegendItemCollection collection = createThresholdLegend(plot); plot.setFixedLegendItems(collection); } if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth); } //renderer.setSeriesPaint(0, Color.BLUE); plot.setRenderer(renderer); logger.debug("OUT"); if (mainThreshold == null) return null; return chart; }
From source file:com.manydesigns.portofino.chart.Chart1DGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultPieDataset dataset = new DefaultPieDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);//w w w . j a v a 2 s .c o m Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper key = new ComparableWrapper((Comparable) current[0]); dataset.setValue(key, (Number) current[1]); if (current.length > 2) { key.setLabel(current[2].toString()); } } JFreeChart chart = createChart(chartDefinition, dataset); chart.setAntiAlias(isAntiAlias()); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno // eventualmente e' il css a fornirne uno chart.setBorderVisible(isBorderVisible()); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot PiePlot plot = (PiePlot) chart.getPlot(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { PieURLGenerator urlGenerator = new ChartPieUrlGenerator(urlExpression); plot.setURLGenerator(urlGenerator); } else { plot.setURLGenerator(null); } // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // hongliangpan add // :?{0} {1} {2} ? ,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // {0}={1}({2}) plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}")); // ?(0.0-1.0) // plot.setForegroundAlpha(1.0f); // imposta la distanza delle etichette dal plot plot.setLabelGap(0.03); // plot.setLabelGenerator(new MyPieSectionLabelGenerator()); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setCircular(true); plot.setBaseSectionOutlinePaint(Color.BLACK); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // ? plot.setForegroundAlpha(1.0f); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, getHeight(), Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.ThermometerChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final Plot plot = chart.getPlot(); final ThermometerPlot thermometerPlot = (ThermometerPlot) plot; if (isShowBorder() == false || isChartSectionOutline() == false) { chart.setBorderVisible(false); thermometerPlot.setOutlineVisible(false); }// www .ja va 2s . c o m if (getThermometerUnits() != null) { thermometerPlot.setUnits(getThermometerUnits().getUnitConstant()); } thermometerPlot.setLowerBound( Math.min(getCriticalRangeLow(), Math.min(getNormalRangeLow(), getWarningRangeLow()))); thermometerPlot.setUpperBound( Math.max(getCriticalRangeHigh(), Math.max(getNormalRangeHigh(), getWarningRangeHigh()))); thermometerPlot.setBulbRadius(getBulbRadius()); thermometerPlot.setColumnRadius(getColumnRadius()); thermometerPlot.setSubrange(ThermometerPlot.CRITICAL, getCriticalRangeLow(), getCriticalRangeHigh()); thermometerPlot.setSubrange(ThermometerPlot.WARNING, getWarningRangeLow(), getWarningRangeHigh()); thermometerPlot.setSubrange(ThermometerPlot.NORMAL, getNormalRangeLow(), getNormalRangeHigh()); if (getMercuryPaint() != null) { thermometerPlot.setMercuryPaint(getMercuryPaint()); } if (getThermometerPaint() != null) { thermometerPlot.setThermometerPaint(getThermometerPaint()); } if (getCriticalRangeColor() != null) { thermometerPlot.setSubrangePaint(ThermometerPlot.CRITICAL, getCriticalRangeColor()); } if (getWarningRangeColor() != null) { thermometerPlot.setSubrangePaint(ThermometerPlot.WARNING, getWarningRangeColor()); } if (getNormalRangeColor() != null) { thermometerPlot.setSubrangePaint(ThermometerPlot.NORMAL, getNormalRangeColor()); } }
From source file:com.manydesigns.portofino.chart.Chart2DGenerator.java
public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); java.util.List<Object[]> result; String query = chartDefinition.getQuery(); logger.info(query);/*from w w w . j a v a 2 s . c om*/ Session session = persistence.getSession(chartDefinition.getDatabase()); result = QueryUtils.runSql(session, query); for (Object[] current : result) { ComparableWrapper x = new ComparableWrapper((Comparable) current[0]); ComparableWrapper y = new ComparableWrapper((Comparable) current[1]); if (current.length > 3) { x.setLabel(current[3].toString()); } if (current.length > 4) { y.setLabel(current[4].toString()); } dataset.setValue((Number) current[2], x, y); } PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) { plotOrientation = PlotOrientation.VERTICAL; } JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation); chart.setAntiAlias(antiAlias); // impostiamo il bordo invisibile // eventualmente e' il css a fornirne uno chart.setBorderVisible(borderVisible); // impostiamo il titolo TextTitle title = chart.getTitle(); title.setFont(titleFont); title.setMargin(10.0, 0.0, 0.0, 0.0); // ottieni il Plot CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if (!StringUtils.isBlank(urlExpression)) { CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression()); renderer.setBaseItemURLGenerator(urlGenerator); } else { renderer.setBaseItemURLGenerator(null); } renderer.setBaseOutlinePaint(Color.BLACK); // /////////////// if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); } // /////////////// // il plot ha sfondo e bordo trasparente // (quindi si vede il colore del chart) plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); // Modifico il toolTip // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})")); // imposta il messaggio se non ci sono dati plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available")); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.GRAY); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); // Category axis CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); // impostiamo la rotazione dell'etichetta if (plot.getOrientation() == PlotOrientation.VERTICAL) { CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0, CategoryLabelWidthType.CATEGORY, 100); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f); // recuperiamo 8 pixel a sinistra plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0)); height = 74; // contiamo gli elementi nel dataset height += 23 * dataset.getColumnCount(); height += 57; } Axis rangeAxis = plot.getRangeAxis(); rangeAxis.setAxisLinePaint(Color.BLACK); rangeAxis.setLabelFont(axisFont); DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier()); plot.setDrawingSupplier(supplier); // ? plot.setForegroundAlpha(1.0f); // impostiamo il titolo della legenda String legendString = chartDefinition.getLegend(); Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0)); subtitle.setMargin(0, 0, 5, 0); chart.addSubtitle(subtitle); // impostiamo la legenda LegendTitle legend = chart.getLegend(); legend.setBorder(0, 0, 0, 0); legend.setItemFont(legendItemFont); int legendMargin = 10; legend.setMargin(0.0, legendMargin, legendMargin, legendMargin); legend.setBackgroundPaint(transparentColor); // impostiamo un gradiente orizzontale Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE); chart.setBackgroundPaint(chartBgPaint); return chart; }
From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java
/** * Creates a chart.//from w w w.j a v a 2 s. c o m * * @return A chart. */ private JFreeChart createChart(String title) { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[subplotCount]; for (int i = 0; i < subplotCount; i++) { this.lastValue[i] = 100.0; final TimeSeries series = new TimeSeries("Real Time", Millisecond.class); this.datasets[i] = new TimeSeriesCollection(series); final NumberAxis rangeAxis = new NumberAxis("Schedule"); rangeAxis.setAutoRangeIncludesZero(false); final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new XYLineAndShapeRenderer()); subplot.setBackgroundPaint(Color.white); subplot.setDomainGridlinePaint(Color.lightGray); subplot.setRangeGridlinePaint(Color.lightGray); plot.add(subplot); } final JFreeChart chart = new JFreeChart(title, plot); chart.removeLegend(); // chart.getLegend().setPosition(RectangleEdge.BOTTOM); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); Paint p = GanttPlotter.getBackgroundColorGradient(); chart.setBackgroundPaint(p); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.black); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); return chart; }
From source file:LoggerGUI.DataLogger.java
public DataLogger(String title) { super(title); initialize();//from www . java 2 s . c o m final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[INPUT_COUNT]; this.lastValue[0] = 100.0; this.lastValue[1] = 100.0; this.lastValue[2] = 100.0; this.lastValue[3] = 100.0; final TimeSeries s0 = new TimeSeries("A0", Millisecond.class); final TimeSeries s1 = new TimeSeries("A1", Millisecond.class); final TimeSeries s2 = new TimeSeries("A2", Millisecond.class); final TimeSeries s3 = new TimeSeries("A3", Millisecond.class); this.datasets[0] = new TimeSeriesCollection(s0); this.datasets[1] = new TimeSeriesCollection(s1); this.datasets[2] = new TimeSeriesCollection(s2); this.datasets[3] = new TimeSeriesCollection(s3); final NumberAxis rangeAxis = new NumberAxis("ADC Signal"); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot; XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true,false); XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true,false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true,false); XYLineAndShapeRenderer renderer3 = new XYLineAndShapeRenderer(true,false); subplot= new XYPlot( new TimeSeriesCollection(), null, rangeAxis, new XYLineAndShapeRenderer(true,false) ); plot.add(subplot); renderer.setBaseShapesVisible(false); renderer.setSeriesPaint(0, Color.red); subplot.setDataset(0,datasets[0]); subplot.setRenderer(0,renderer); renderer1.setBaseShapesVisible(false); renderer1.setSeriesPaint(0, Color.blue); subplot.setDataset(1,datasets[1]); subplot.setRenderer(1,renderer1); renderer2.setBaseShapesVisible(false); renderer2.setSeriesPaint(0, Color.black); subplot.setDataset(2,datasets[2]); subplot.setRenderer(2,renderer2); subplot.getRendererForDataset(subplot.getDataset(0)).setSeriesPaint(0, Color.red); subplot.getRendererForDataset(subplot.getDataset(1)).setSeriesPaint(1, Color.blue); subplot.getRendererForDataset(subplot.getDataset(2)).setSeriesPaint(2, Color.black); renderer3.setBaseShapesVisible(false); renderer3.setSeriesPaint(0, Color.green); subplot.setDataset(3,datasets[3]); subplot.setRenderer(3,renderer3); final JFreeChart chart = new JFreeChart("Data Logger", plot); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); // 60 seconds final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JPanel buttonPanel = new JPanel(new FlowLayout()); content.add(buttonPanel, BorderLayout.NORTH); chartPanel.setPreferredSize(new java.awt.Dimension(600, 600)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); }
From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java
@Override protected JFreeChart createChart() { // create the chart... pieDataSet = createDataset();/*from ww w . j ava2s . co m*/ final JFreeChart chart = ChartFactory.createPieChart3D("", // chart // title pieDataSet, // data false, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.getTitle().setPaint(new Color(0x5E5E5E)); chart.setBorderVisible(false); // set the background color for the chart... final PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setOutlineVisible(false); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setStartAngle(290); plot.setBackgroundPaint(Color.white); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new JFreeChartLabelCustom()); final List keys = pieDataSet.getKeys(); for (int i = 0; i < keys.size(); i++) { final Comparable key = (Comparable) keys.get(i); plot.setSectionPaint(key, Color.decode( "0x" + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length])); } // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:project16.Home16.java
void RenderChart() { CategoryDataset ds = createDataset(); JFreeChart chart = ChartFactory.createStackedAreaChart("", "", "", ds); chart.setBackgroundPaint(new Color(54, 63, 73)); chart.setBorderVisible(false); chart.setBorderPaint(new Color(54, 63, 73)); chart.getCategoryPlot().setBackgroundPaint(new Color(54, 63, 73)); chart.getCategoryPlot().setDomainGridlinePaint(new Color(54, 63, 73)); chart.getCategoryPlot().setDomainGridlinesVisible(false); chart.getCategoryPlot().setOutlinePaint(new Color(54, 63, 73)); ChartPanel cp = new ChartPanel(chart); cp.setBackground(new Color(54, 63, 73)); pnl_chart.add(cp, BorderLayout.CENTER); pnl_chart.validate();/* w w w.j a v a 2 s . c om*/ }
From source file:systeminformation.Chart.java
public JFreeChart create3DPieChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("", dataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); p.setLabelGenerator(gen);//from w w w . jav a2 s . com // p.setSimpleLabels(true); p.setForegroundAlpha(0.5f); p.setBackgroundAlpha(0.2f); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); chart.setBorderVisible(true); return chart; }