List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.jfree.chart.demo.RelativeDateFormatDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Exercise Chart", "Elapsed Time", "Beats Per Minute", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/*from ww w. j a v a 2 s . com*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); Minute minute = new Minute(0, 9, 1, 10, 2006); RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond()); relativedateformat.setSecondFormatter(new DecimalFormat("00")); dateaxis.setDateFormatOverride(relativedateformat); return jfreechart; }
From source file:org.jfree.chart.demo.PeriodAxisDemo3.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("Maximum Temperature", "Day", true, "Temperature", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); PeriodAxis periodaxis = new PeriodAxis("Day"); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("E"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);/*from w ww . j a v a 2 s .c om*/ return jfreechart; }
From source file:org.jfree.chart.demo.XYErrorRendererDemo1.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { NumberAxis numberaxis = new NumberAxis("X"); NumberAxis numberaxis1 = new NumberAxis("Y"); XYErrorRenderer xyerrorrenderer = new XYErrorRenderer(); XYPlot xyplot = new XYPlot(intervalxydataset, numberaxis, numberaxis1, xyerrorrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); JFreeChart jfreechart = new JFreeChart("XYErrorRenderer Demo 1", xyplot); jfreechart.setBackgroundPaint(Color.white); return jfreechart; }
From source file:org.jfree.chart.demo.XYErrorRendererDemo2.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { NumberAxis numberaxis = new NumberAxis("X"); NumberAxis numberaxis1 = new NumberAxis("Y"); XYErrorRenderer xyerrorrenderer = new XYErrorRenderer(); xyerrorrenderer.setBaseLinesVisible(true); xyerrorrenderer.setBaseShapesVisible(false); XYPlot xyplot = new XYPlot(intervalxydataset, numberaxis, numberaxis1, xyerrorrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); JFreeChart jfreechart = new JFreeChart("XYErrorRenderer Demo 2", xyplot); jfreechart.setBackgroundPaint(Color.white); return jfreechart; }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries *///from ww w.j a v a 2 s . com public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:org.jfree.chart.demo.ClusteredXYBarRendererDemo1.java
private static JFreeChart createChart(String s, IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart(s, null, true, "Y", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ClusteredXYBarRenderer clusteredxybarrenderer = new ClusteredXYBarRenderer(0.20000000000000001D, false); xyplot.setRenderer(clusteredxybarrenderer); return jfreechart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }/*from ww w .j a va2s .c o m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return jfreechart; }
From source file:org.jfree.chart.demo.PeriodAxisDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); }/*w w w.ja v a 2 s . c om*/ PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); return jfreechart; }
From source file:org.jfree.chart.demo.XYSplineRendererDemo1a.java
public static JPanel createDemoPanel() { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(createSampleData(), 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("XYSplineRenderer", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); return chartpanel; }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title, String categoryAxisLabel, String valueAxisLabel, long timeRefresh) { final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100); chart.setBackgroundPaint(Color.lightGray); ChartPanel localChartPanel = new ChartPanel(chart); localChartPanel.setVisible(true);/*from w ww . ja va2 s .c o m*/ localChartPanel.setDomainZoomable(true); return localChartPanel; }