List of usage examples for org.jfree.chart.axis NumberAxis setAutoRangeIncludesZero
public void setAutoRangeIncludesZero(boolean flag)
From source file:playground.wrashid.tryouts.mess.Boxplot.java
/** * @param args/*from w w w. jav a 2 s . c om*/ */ public static void main(String[] args) { final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Box-and-Whisker Demo", "x", "y", dataset, true); final ChartPanel chartPanel = new ChartPanel(chart); int width = 500; int height = 300; try { ChartUtilities.saveChartAsPNG(new File("boxPlot.png"), chart, width, height); } catch (IOException e) { } }
From source file:org.jfree.chart.demo.ImageMapDemo7.java
/** * Starting point for the demo./*w w w.j av a 2 s .c o m*/ * * @param args ignored. */ public static void main(final String[] args) { final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); // final Legend legend = chart.getLegend(); // if (legend instanceof StandardLegend) { // final StandardLegend sl = (StandardLegend) legend; // sl.setDisplaySeriesShapes(true); //} final NumberAxis domainAxis = (NumberAxis) chart.getXYPlot().getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("scatter100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("scatter100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"scatter100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:ta4jexamples.indicators.CandlestickChart.java
public static void main(String[] args) { /**/* www .ja va2 s . c o m*/ * Getting time series */ TimeSeries series = CsvTradesLoader.loadBitstampSeries(); /** * Creating the OHLC dataset */ OHLCDataset ohlcDataset = createOHLCDataset(series); /** * Creating the additional dataset */ TimeSeriesCollection xyDataset = createAdditionalDataset(series); /** * Creating the chart */ JFreeChart chart = ChartFactory.createCandlestickChart("Bitstamp BTC price", "Time", "USD", ohlcDataset, true); // Candlestick rendering CandlestickRenderer renderer = new CandlestickRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); // Additional dataset int index = 1; plot.setDataset(index, xyDataset); plot.mapDatasetToRangeAxis(index, 0); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesPaint(index, Color.blue); plot.setRenderer(index, renderer2); // Misc plot.setRangeGridlinePaint(Color.lightGray); plot.setBackgroundPaint(Color.white); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setAutoRangeIncludesZero(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); /** * Displaying the chart */ displayChart(chart); }
From source file:org.jfree.chart.demo.ImageMapDemo3.java
/** * Starting point for the demo./*from w ww . j a va2 s . co m*/ * * @param args ignored. * * @throws ParseException if there is a problem parsing dates. */ public static void main(final String[] args) throws ParseException { // Create a sample dataset final SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy"); final XYSeries dataSeries = new XYSeries("Curve data"); final ArrayList toolTips = new ArrayList(); dataSeries.add(sdf.parse("01-Jul-2002").getTime(), 5.22); toolTips.add("1D - 5.22"); dataSeries.add(sdf.parse("02-Jul-2002").getTime(), 5.18); toolTips.add("2D - 5.18"); dataSeries.add(sdf.parse("03-Jul-2002").getTime(), 5.23); toolTips.add("3D - 5.23"); dataSeries.add(sdf.parse("04-Jul-2002").getTime(), 5.15); toolTips.add("4D - 5.15"); dataSeries.add(sdf.parse("05-Jul-2002").getTime(), 5.22); toolTips.add("5D - 5.22"); dataSeries.add(sdf.parse("06-Jul-2002").getTime(), 5.25); toolTips.add("6D - 5.25"); dataSeries.add(sdf.parse("07-Jul-2002").getTime(), 5.31); toolTips.add("7D - 5.31"); dataSeries.add(sdf.parse("08-Jul-2002").getTime(), 5.36); toolTips.add("8D - 5.36"); final XYSeriesCollection xyDataset = new XYSeriesCollection(dataSeries); final CustomXYToolTipGenerator ttg = new CustomXYToolTipGenerator(); ttg.addToolTipSeries(toolTips); // Create the chart final StandardXYURLGenerator urlg = new StandardXYURLGenerator("xy_details.jsp"); final ValueAxis timeAxis = new DateAxis(""); final NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(xyDataset, timeAxis, valueAxis, null); final StandardXYItemRenderer sxyir = new StandardXYItemRenderer( StandardXYItemRenderer.LINES + StandardXYItemRenderer.SHAPES, ttg, urlg); sxyir.setShapesFilled(true); plot.setRenderer(sxyir); final JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("xychart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("xychart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"xychart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } return; }
From source file:org.jfree.chart.demo.LineChart3DDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart3D("Line Chart 3D Demo 1", null, "Class Count", categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(new Color(187, 187, 221)); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 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:org.jfree.chart.demo.ScatterPlotDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setNoDataMessage("NO DATA"); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.black); xylineandshaperenderer.setUseOutlinePaint(true); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setTickMarkInsideLength(2.0F); numberaxis.setTickMarkOutsideLength(0.0F); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setTickMarkInsideLength(2.0F); numberaxis1.setTickMarkOutsideLength(0.0F); return jfreechart; }
From source file:org.jfree.chart.demo.XYShapeRendererDemo1.java
private static JFreeChart createChart(XYZDataset xyzdataset) { NumberAxis numberaxis = new NumberAxis("X"); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("Y"); numberaxis1.setAutoRangeIncludesZero(false); XYShapeRenderer xyshaperenderer = new XYShapeRenderer(); LookupPaintScale lookuppaintscale = new LookupPaintScale(1.0D, 4D, new Color(0, 0, 255)); lookuppaintscale.add(2D, new Color(100, 100, 255)); lookuppaintscale.add(3D, new Color(200, 200, 255)); xyshaperenderer.setPaintScale(lookuppaintscale); XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyshaperenderer); xyplot.setDomainPannable(true);/*w w w .j av a 2s . c o m*/ xyplot.setRangePannable(true); JFreeChart jfreechart = new JFreeChart("XYShapeRendererDemo1", xyplot); jfreechart.removeLegend(); NumberAxis numberaxis2 = new NumberAxis("Score"); numberaxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, numberaxis2); paintscalelegend.setPosition(RectangleEdge.RIGHT); paintscalelegend.setMargin(4D, 4D, 40D, 4D); paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); jfreechart.addSubtitle(paintscalelegend); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.DeviationRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); //A specialised subclass of the {@link XYLineAndShapeRenderer} that requires // an {@link IntervalXYDataset} and represents the y-interval by shading an // area behind the y-values on the chart. DeviationRenderer renderer = new DeviationRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, new Color(255, 200, 200)); renderer.setSeriesFillPaint(1, new Color(200, 200, 255)); plot.setRenderer(renderer);/*from w w w . j a va 2 s .co m*/ // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.jfree.chart.demo.DeviationRendererDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ///*w ww. j av a 2 s . com*/ DeviationRenderer renderer = new DeviationRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, new Color(255, 200, 200)); renderer.setSeriesFillPaint(1, new Color(200, 200, 255)); plot.setRenderer(renderer); // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }