List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
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 ava 2 s .c om 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; }
From source file:org.jfree.chart.demo.TimeSeriesDemo.java
/** * Creates a chart./* w w w . java 2 s . c o m*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", 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); rr.setItemLabelsVisible(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:org.jfree.chart.demo.XYAreaChartTest.java
/** * Creates a chart./*from ww w. j a v a 2 s .c o m*/ * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Test", "Domain (X)", "Range (Y)", dataset, PlotOrientation.VERTICAL, true, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); //plot.setOutlinePaint(Color.black); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.65f); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRenderer(new XYAreaRenderer2()); final ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarkPaint(Color.black); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); final ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickMarkPaint(Color.black); return chart; }
From source file:chart.JChartSegment.java
/** * Creates a sample chart./* ww w. ja v a2 s . c o m*/ * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset, List<NSubsequence> subsequence) { final JFreeChart chart = ChartFactory.createXYLineChart("Test", "Time", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); MyRender renderer = new MyRender(dataset, subsequence); plot.setRenderer(renderer); renderer.setSeriesShapesVisible(0, false); chart.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); return chart; }
From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java
public ChartPanel createChartPanel() { XYDataset dataset = createDataset(); NumberAxis numberaxis = new NumberAxis("EMAILS"); numberaxis.setAutoRangeIncludesZero(true); numberaxis.setRange(0, dataset.getItemCount(1)); numberaxis.setVisible(false);/* w w w . j a v a2 s .c om*/ NumberAxis numberaxis1 = new NumberAxis("TIME CONSUMED"); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(dataset, numberaxis, numberaxis1, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); //xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart("PLAN VALUES FOR '" + sName + "' SCHEDULER", new Font(Font.SANS_SERIF, Font.PLAIN, 11), xyplot, true); chartPanel = new ChartPanel(jfreechart, true); //Creating listener chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { ChartEntity entity = e.getEntity(); if (entity != null && (entity instanceof XYItemEntity)) { XYItemEntity item = (XYItemEntity) entity; String chartTitle = "RULE ARRANGEMENT INFORMATION FOR EMAIL \"" + dataSource.get(item.getItem()).getEmailName() + "\""; createSubChart( new CreateStackedBarChart3D(dataSource.get(item.getItem()), pluginColor, chartTitle) .createChartPanel()); } } @Override public void chartMouseMoved(ChartMouseEvent e) { //DO NOTHING } }); return chartPanel; }
From source file:EHRAppointment.ChartPanelDraw.java
private ChartPanel createChart(XYDataset dataset, String type) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(type, "Date", getValueAxis(), dataset); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); plot.setRenderer(renderer);//from www. j a v a2 s .c o m final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return new ChartPanel(chart); }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo2.java
/** * Creates a chart./*from www .j av a 2 s . co m*/ * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.TimeChartRenderer.java
public void createChart() { XYDataset dataset = (XYDataset) this.datasetStrategy.getDataset(); report = ChartFactory.createTimeSeriesChart(this.datasetStrategy.getTitle(), // title this.datasetStrategy.getXAxisLabel(), // x-axis label this.datasetStrategy.getYAxisLabel(), // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? );/* w w w. j av a2 s. com*/ // report.setBackgroundPaint( Color.lightGray ); XYPlot plot = report.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); XYItemRenderer xyitemrenderer = plot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyitemrenderer; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setBaseItemLabelGenerator( ((AbstractTimeChartStrategy) this.datasetStrategy).getLabelGenerator()); renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, 10)); renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT)); } Paint[] paints = this.datasetStrategy.getPaintColor(); for (int i = 0; i < dataset.getSeriesCount() && i < paints.length; i++) { xyitemrenderer.setSeriesPaint(i, paints[i]); xyitemrenderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); } plot.setRangeAxis(((AbstractTimeChartStrategy) this.datasetStrategy).getRangeAxis()); DashDateAxis axisDate = new DashDateAxis(); axisDate.setDateFormatOverride( ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod().getDateFormat()); axisDate.setLabel(this.datasetStrategy.getXAxisLabel()); axisDate.setTickUnit(getTickUnit(((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod())); axisDate.setUpperMargin(0.0D); axisDate.setDateTickLabelAngle(-0.6); if (((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate() != null && ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate() != null) { axisDate.setRangeWithMargins( new DateRange(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(), ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate())); } plot.setDomainAxis(axisDate); Date[] dates = DateUtils.getAllDates(((AbstractTimeChartStrategy) this.datasetStrategy).getStartDate(), ((AbstractTimeChartStrategy) this.datasetStrategy).getEndDate(), ((AbstractTimeChartStrategy) this.datasetStrategy).getTimePeriod()); int width = (dates.length * ChartUtils.STANDARD_TIME_ENTRY_WIDTH) + ChartUtils.STANDARD_TIME_ADDITIONAL_WIDTH; if (width > ChartUtils.MINIMUM_WIDTH) { this.setWidth(width); } else { this.setWidth(ChartUtils.MINIMUM_WIDTH); } }
From source file:org.jfree.chart.demo.TimeSeriesDemo12.java
/** * Creates a chart.//from www . j a v a 2s . c o m * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sample Chart", "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.setOutlinePaint(null); 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(false); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("hh:mma")); return chart; }
From source file:web.diva.server.model.LineChartGenerator.java
/** * Creates a chart./* w ww .j a v a 2s . co m*/ * * @param dataset the data for the chart. * @param lcr the line chart result * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, String[] colors, String[] columnIds, int[] selection) { final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "", // x axis label "", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); if (selection == null) { for (int x = 0; x < colors.length; x++) { renderer.setSeriesShapesVisible(x, false); renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[x])); } } else { for (int x = 0; x < selection.length; x++) { renderer.setSeriesShapesVisible(x, false); renderer.setSeriesPaint(x, imgGenerator.hex2Rgb(colors[selection[x]])); } } plot.setRenderer(renderer); SymbolAxis rangeAxis = new SymbolAxis("", columnIds); rangeAxis.setGridBandsVisible(false); rangeAxis.setVerticalTickLabels(true); rangeAxis.setVisible(true); // rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 1)); rangeAxis.setFixedDimension(51.0); boolean auto = rangeAxis.getAutoRangeIncludesZero(); rangeAxis.setAutoRangeIncludesZero(true ^ auto); rangeAxis.setTickUnit(new NumberTickUnit(1)); rangeAxis.setRange(0, columnIds.length); plot.setDomainAxis(rangeAxis); return chart; }