List of usage examples for org.jfree.chart.renderer.xy XYAreaRenderer2 XYAreaRenderer2
public XYAreaRenderer2()
From source file:org.jfree.chart.demo.XYAreaRenderer2Demo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart("XYAreaRenderer2Demo1", "Domain (X)", "Range (Y)", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setRenderer(new XYAreaRenderer2()); xyplot.setForegroundAlpha(0.65F);/*from w ww. j a v a2s.c o m*/ ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); return jfreechart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYAreaChartExpression.java
public static JFreeChart createTimeSeriesChart(final String title, final String timeAxisLabel, final String valueAxisLabel, final XYDataset dataset, final boolean legend, final boolean tooltips, final boolean urls, final boolean stacked) { final ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);/*from www. j a v a 2 s . co m*/ final NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } final XYAreaRenderer2 renderer; if (stacked) { renderer = new StackedXYAreaRenderer2(); } else { renderer = new XYAreaRenderer2(); } renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
From source file:org.jfree.chart.demo.XYAreaChartTest.java
/** * Creates a chart.// w w w .ja v a 2s . co 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:org.drools.planner.benchmark.core.statistic.memoryuse.MemoryUseProblemStatistic.java
protected void writeGraphStatistic() { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (SingleBenchmark singleBenchmark : problemBenchmark.getSingleBenchmarkList()) { MemoryUseSingleStatistic singleStatistic = (MemoryUseSingleStatistic) singleBenchmark .getSingleStatistic(problemStatisticType); XYSeries usedSeries = new XYSeries(singleBenchmark.getSolverBenchmark().getName() + " used"); XYSeries maxSeries = new XYSeries(singleBenchmark.getSolverBenchmark().getName() + " max"); for (MemoryUseSingleStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpend = point.getTimeMillisSpend(); MemoryUseMeasurement memoryUseMeasurement = point.getMemoryUseMeasurement(); usedSeries.add(timeMillisSpend, memoryUseMeasurement.getUsedMemory()); maxSeries.add(timeMillisSpend, memoryUseMeasurement.getMaxMemory()); }/*from w w w . jav a2 s . c o m*/ seriesCollection.addSeries(usedSeries); seriesCollection.addSeries(maxSeries); } NumberAxis xAxis = new NumberAxis("Time spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Memory"); yAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new XYAreaRenderer2(); XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(problemBenchmark.getName() + " memory use statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); graphStatisticFile = new File(problemBenchmark.getProblemReportDirectory(), problemBenchmark.getName() + "MemoryUseStatistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } }
From source file:org.drools.planner.benchmark.statistic.memoryuse.MemoryUseStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (Map.Entry<String, MemoryUseStatisticListener> listenerEntry : statisticListenerMap.entrySet()) { String configName = listenerEntry.getKey(); XYSeries usedSeries = new XYSeries(configName + " used"); XYSeries maxSeries = new XYSeries(configName + " max"); List<MemoryUseStatisticPoint> statisticPointList = listenerEntry.getValue().getStatisticPointList(); for (MemoryUseStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); MemoryUseMeasurement memoryUseMeasurement = statisticPoint.getMemoryUseMeasurement(); usedSeries.add(timeMillisSpend, memoryUseMeasurement.getUsedMemory()); maxSeries.add(timeMillisSpend, memoryUseMeasurement.getMaxMemory()); }//from w ww . ja va2s . co m seriesCollection.addSeries(usedSeries); seriesCollection.addSeries(maxSeries); } NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Memory"); yAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new XYAreaRenderer2(); XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " memory use statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "MemoryUseStatistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.jstockchart.plot.TimeseriesPlot.java
private XYPlot createVolumePlot() { Font axisFont = new Font("Arial", 0, 12); Stroke stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); VolumeArea volumeArea = timeseriesArea.getVolumeArea(); LogicNumberAxis logicVolumeAxis = volumeArea.getLogicVolumeAxis(); Color volumeColor = new Color(86, 126, 160); volumeArea.setVolumeColor(volumeColor); CFXNumberAxis volumeAxis = new CFXNumberAxis(logicVolumeAxis.getLogicTicks()); volumeAxis.setAxisLineVisible(false); volumeAxis.setCustomTickCount(2);//w ww . j a va 2 s.co m volumeAxis.setTickLabelPaint(volumeColor); volumeAxis.setUpperBound(logicVolumeAxis.getUpperBound()); volumeAxis.setTickLabelFont(axisFont); volumeAxis.setTickMarkStroke(stroke); volumeAxis.setLowerBound(logicVolumeAxis.getLowerBound()); volumeAxis.setAutoRangeIncludesZero(true); XYAreaRenderer2 volumeRenderer = new XYAreaRenderer2(); volumeRenderer.setSeriesPaint(0, volumeArea.getVolumeColor()); //volumeRenderer.setShadowVisible(false); volumeRenderer.setSeriesStroke(0, stroke); volumeRenderer.setBaseStroke(stroke); XYPlot plot = new XYPlot(new TimeSeriesCollection(dataset.getVolumeTimeSeries()), null, volumeAxis, volumeRenderer); plot.setBackgroundPaint(volumeArea.getBackgroudColor()); plot.setOrientation(volumeArea.getOrientation()); plot.setRangeAxisLocation(volumeArea.getVolumeAxisLocation()); plot.setRangeMinorGridlinesVisible(false); Stroke outLineStroke = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.CAP_SQUARE, 0.0f, new float[] { 1.0f, 1.0f }, 1.0f); Stroke gridLineStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 2.0f, 2.0f }, 1.0f); // plot.setBackgroundPaint(Color.RED); plot.setRangeGridlineStroke(gridLineStroke); plot.setDomainGridlineStroke(gridLineStroke); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(true); plot.setOutlineVisible(true); plot.setOutlineStroke(outLineStroke); plot.setOutlinePaint(Color.black); plot.setRangeZeroBaselineVisible(true); return plot; }