List of usage examples for org.jfree.chart.axis ValueAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createXYAreaChart(String title, String xLabel, String yLabel, XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart(title, xLabel, yLabel, dataset, orientation, true, // legend true, // tool tips false // URLs );//from ww w .j a v a2 s .co m chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.65f); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); if (timeType.length() != 0) { setDateAxis(plot); } else { ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarkPaint(Color.black); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickMarkPaint(Color.black); } //XYItemRenderer renderer = plot.getRenderer(); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); return chart; }
From source file:org.jfree.chart.ChartFactory.java
/** * Creates and returns a time series chart. A time series chart is an * {@link XYPlot} with a {@link DateAxis} for the x-axis and a * {@link NumberAxis} for the y-axis. The default renderer is an * {@link XYLineAndShapeRenderer}./*from w ww . ja va 2 s. c o m*/ * <P> * A convenient dataset to use with this chart is a * {@link org.jfree.data.time.TimeSeriesCollection}. * * @param title the chart title ({@code null} permitted). * @param timeAxisLabel a label for the time axis ({@code null} * permitted). * @param valueAxisLabel a label for the value axis ({@code null} * permitted). * @param dataset the dataset for the chart ({@code null} permitted). * * @return A time series chart. */ public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset) { ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setDefaultToolTipGenerator(toolTipGenerator); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(title, plot); currentTheme.apply(chart); return chart; }