List of usage examples for org.jfree.chart JFreeChart setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createHighLowChart(XYDataset dataset) { ValueAxis timeAxis = new DateAxis(xAxisLabel); NumberAxis valueAxis = new NumberAxis(yAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart("HighLow Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createWaferMapChart(WaferMapDataset dataset) { WaferMapPlot plot = new WaferMapPlot(dataset); WaferMapRenderer renderer = new WaferMapRenderer(); plot.setRenderer(renderer);/*from w w w.j a v a2 s.c o m*/ JFreeChart chart = new JFreeChart("WaferMap Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createHighLowChart(OHLCDataset dataset) { ValueAxis timeAxis = new DateAxis(xAxisLabel); NumberAxis valueAxis = new NumberAxis(yAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart("HighLow Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createPolarChart(XYDataset dataset) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset);//from w w w .ja v a 2s .com NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setAngleGridlinesVisible(true); plot.setAngleLabelsVisible(true); plot.setAngleTickUnit(new NumberTickUnit(5)); return chart; }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createXYLineChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation);//from w ww . ja v a 2s . c om if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart("XYLine Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat()); return chart; }
From source file:com.opensourcestrategies.crmsfa.reports.JFreeCrmsfaCharts.java
/** * Opportunities by stage. Description at * http://www.opentaps.org/docs/index.php/CRMSFA_Dashboard * Note that this counts all the opportunities in the system for now. *//*from w w w . java 2 s. c om*/ public static String createOpportunitiesbyStageChart(Delegator delegator, Locale locale) throws GenericEntityException, IOException { Map uiLabelMap = UtilMessage.getUiLabels(locale); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String currency = UtilConfig.getPropertyValue("crmsfa", "defaultCurrencyUomId"); // get all sales opportunity stages that are not closed, or lost List<GenericValue> salesOpportunityStages = ReportHelper .findSalesOpportunityStagesForDashboardReporting(delegator); // report number of leads for each status for (GenericValue stage : salesOpportunityStages) { String opportunityStageId = stage.getString("opportunityStageId"); EntityCondition conditions = EntityCondition.makeCondition(EntityOperator.AND, EntityCondition.makeCondition("opportunityStageId", EntityOperator.EQUALS, opportunityStageId), EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currency)); List<GenericValue> salesOpportunityEstimatedAmountTotals = delegator .findByConditionCache("SalesOpportunityEstimatedAmountTotalByStage", conditions, null, null); if (salesOpportunityEstimatedAmountTotals != null && !salesOpportunityEstimatedAmountTotals.isEmpty()) { GenericValue salesOpportunityEstimatedAmountTotal = salesOpportunityEstimatedAmountTotals.get(0); dataset.addValue(salesOpportunityEstimatedAmountTotal.getDouble("estimatedAmountTotal"), "", (String) stage.get("description", locale)); } else { dataset.addValue(0, "", (String) stage.get("description", locale)); } } // set up the chart JFreeChart chart = ChartFactory.createBarChart( (String) UtilMessage.expandLabel("CrmOpportunitiesbyStage", locale, UtilMisc.toMap("currency", currency)), null, null, dataset, PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // get the bar renderer to put effects on the bars final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // disable bar outlines // set up gradient paint on bar final GradientPaint gp = new GradientPaint(0.0f, 0.0f, new Color(206, 246, 245), 0.0f, 0.0f, new Color(51, 204, 204)); renderer.setSeriesPaint(0, gp); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // save as a png and return the file name return ServletUtilities.saveChartAsPNG(chart, 360, 200, null); }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createCandlestickChart(OHLCDataset dataset) { ValueAxis timeAxis = new DateAxis(xAxisLabel); NumberAxis valueAxis = new NumberAxis(yAxisLabel); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart("Candlestick Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createWindChart(WindDataset dataset) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis("Direction / Force"); yAxis.setRange(-12.0, 12.0);/*from w w w . jav a 2 s . c o m*/ WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart("Wind Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createHistogramChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); ValueAxis yAxis = new NumberAxis(yAxisLabel); XYItemRenderer renderer = new XYBarRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); }//from w w w .j a v a 2 s . c o m if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); JFreeChart chart = new JFreeChart("Histogram Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createXYAreaChart(XYDataset dataset) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setOrientation(orientation);/*from w w w .j a v a2 s. c o m*/ plot.setForegroundAlpha(0.5f); XYToolTipGenerator tipGenerator = null; if (tooltips) { tipGenerator = new StandardXYToolTipGenerator(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator)); JFreeChart chart = new JFreeChart("XYArea Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat()); return chart; }