List of usage examples for org.jfree.chart JFreeChart setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.jfree.chart.demo.MultiplePieChartDemo4.java
/** * Creates a sample chart for the given dataset. * /*from w ww. jav a 2s. co m*/ * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset, TableOrder.BY_COLUMN, false, true, false); chart.setBackgroundPaint(new Color(216, 255, 216)); final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); final JFreeChart subchart = plot.getPieChart(); // final StandardLegend legend = new StandardLegend(); // legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8)); // legend.setAnchor(Legend.SOUTH); // subchart.setLegend(legend); plot.setLimit(0.10); final PiePlot p = (PiePlot) subchart.getPlot(); p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}")); p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8)); p.setInteriorGap(0.30); return chart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo13.java
/** * Creates a chart.//from ww w. j a va 2 s.c o m * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Weekly Data", "Date", "Value", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); final TickUnits standardUnits = new TickUnits(); standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 1, new SimpleDateFormat("MMM dd ''yy"))); standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("MMM dd ''yy"))); standardUnits.add(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("MMM ''yy"))); axis.setStandardTickUnits(standardUnits); return chart; }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.StufenBarChart.java
protected JFreeChart createBarChart(Object dataset) { final float plotForegroundAlpha = 0.6f; JFreeChart chart = ChartFactory.createStackedBarChart3D(null, Messages.StufenBarChart_1, Messages.StufenBarChart_2, (CategoryDataset) dataset, PlotOrientation.HORIZONTAL, false, true, false);/*from ww w . jav a 2s .c om*/ chart.setBackgroundPaint(Color.white); chart.getPlot().setForegroundAlpha(plotForegroundAlpha); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD); return chart; }
From source file:ws.moor.bt.grapher.ChartBuilder.java
public JFreeChart getChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries, showLegend && (timeSeries.getSeriesCount() > 1), false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot();// w w w.j a va 2s. c om plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getRenderer().setSeriesPaint(0, Color.black); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesPaint(1, Color.black); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesPaint(2, Color.black); plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f)); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:org.jfree.chart.demo.DualAxisDemo5.java
/** * Creates a chart./*www .j a v a2 s . co m*/ * * @param dataset1 the first dataset. * @param dataset2 the second dataset. * * @return A chart. */ private JFreeChart createChart(final CategoryDataset dataset1, final CategoryDataset dataset2) { final CategoryAxis domainAxis = new CategoryAxis("Category"); final NumberAxis rangeAxis = new NumberAxis("Value"); final BarRenderer renderer1 = new BarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset1, domainAxis, rangeAxis, renderer1) { /** * Override the getLegendItems() method to handle special case. * * @return the legend items. */ public LegendItemCollection getLegendItems() { final LegendItemCollection result = new LegendItemCollection(); final CategoryDataset data = getDataset(); if (data != null) { final CategoryItemRenderer r = getRenderer(); if (r != null) { final LegendItem item = r.getLegendItem(0, 0); result.add(item); } } // the JDK 1.2.2 compiler complained about the name of this // variable final CategoryDataset dset2 = getDataset(1); if (dset2 != null) { final CategoryItemRenderer renderer2 = getRenderer(1); if (renderer2 != null) { final LegendItem item = renderer2.getLegendItem(1, 1); result.add(item); } } return result; } }; final JFreeChart chart = new JFreeChart("Dual Axis Bar Chart", plot); chart.setBackgroundPaint(Color.white); // chart.getLegend().setAnchor(Legend.SOUTH); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final ValueAxis axis2 = new NumberAxis("Secondary"); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); final BarRenderer renderer2 = new BarRenderer(); plot.setRenderer(1, renderer2); return chart; }
From source file:slash.navigation.converter.gui.profileview.ProfileView.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart(null, null, null, dataset, VERTICAL, false, true, false); chart.setBackgroundPaint(new JPanel().getBackground()); return chart; }
From source file:datavis.BarGraph.java
public JFreeChart getChartPanel() { JFreeChart chart = ChartFactory.createBarChart(getBarGraphName(), getIntervalTypeName(), getNumberTypeName(), getBarGraph(), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.darkGray); plot.setDomainGridlinePaint(new Color(240, 180, 180)); plot.setRangeGridlinePaint(new Color(240, 180, 180)); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(170, 240, 240), 0.0f, 0.0f, new Color(170, 240, 240)); renderer.setSeriesPaint(0, gp0);//from w w w . j a v a2s . co m final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:bzstats.chart.KillRatioHistoryChart.java
protected JFreeChart getChart() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); fillDataset(dataset);/*from w ww. jav a 2 s . c o m*/ XYPlot plot = new XYPlot(); NumberAxis xaxis = new NumberAxis("Time"); xaxis.setTickLabelsVisible(false); NumberAxis yaxis = new NumberAxis("Killratio"); plot.setDomainAxis(xaxis); plot.setRangeAxis(yaxis); plot.setDataset(dataset); plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); JFreeChart chart = new JFreeChart("Killratio", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.addSubtitle(new TextTitle("kills/deaths")); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.jfree.chart.demo.OverlaidBarChartDemo2.java
/** * Creates a sample chart.//from w ww . j av a2 s.c om * * @return A sample chart. */ private JFreeChart createChart() { // create the first dataset... DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.addValue(1.0, "S1", "Category 1"); dataset1.addValue(4.0, "S1", "Category 2"); dataset1.addValue(3.0, "S1", "Category 3"); dataset1.addValue(5.0, "S1", "Category 4"); dataset1.addValue(5.0, "S1", "Category 5"); dataset1.addValue(5.0, "S2", "Category 1"); dataset1.addValue(7.0, "S2", "Category 2"); dataset1.addValue(6.0, "S2", "Category 3"); dataset1.addValue(8.0, "S2", "Category 4"); dataset1.addValue(4.0, "S2", "Category 5"); // create the first plot... final CategoryItemRenderer renderer = new BarRenderer(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset1); plot.setRenderer(renderer); plot.setDomainAxis(new CategoryAxis("Category")); plot.setRangeAxis(new NumberAxis("Value")); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.addValue(6.0, "Prior 1", "Category 1"); dataset2.addValue(7.0, "Prior 1", "Category 2"); dataset2.addValue(2.0, "Prior 1", "Category 3"); dataset2.addValue(6.0, "Prior 1", "Category 4"); dataset2.addValue(6.0, "Prior 1", "Category 5"); dataset2.addValue(4.0, "Prior 2", "Category 1"); dataset2.addValue(2.0, "Prior 2", "Category 2"); dataset2.addValue(1.0, "Prior 2", "Category 3"); dataset2.addValue(3.0, "Prior 2", "Category 4"); dataset2.addValue(2.0, "Prior 2", "Category 5"); final CategoryItemRenderer renderer2 = new LevelRenderer(); renderer2.setSeriesStroke(0, new BasicStroke(2.0f)); renderer2.setSeriesStroke(1, new BasicStroke(2.0f)); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); final JFreeChart chart = new JFreeChart(plot); chart.setTitle("Overlaid Bar Chart"); // chart.setLegend(new StandardLegend()); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.evosuite.jenkins.plot.Plot.java
@Override protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, "Build Number #", this.yLabel, this.dataset, PlotOrientation.VERTICAL, true, true, true); chart.setBackgroundPaint(Color.WHITE); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0);//from www . j a v a2 s .c o m domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); plot.setBackgroundPaint(Color.WHITE); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //yAxis.setRange(0.0, 100.0); URLAndTooltipRenderer urlRenderer = new URLAndTooltipRenderer(this.project.getProject()); ColorPalette.apply(urlRenderer); plot.setRenderer(urlRenderer); return chart; }