Java Code Examples for org.jfree.chart.plot.XYPlot#setInsets()

The following examples show how to use org.jfree.chart.plot.XYPlot#setInsets() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChartUtils.java    From PDV with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set line style
 * @param plot XYPlot
 */
public static void setLineRender(XYPlot plot) {
    plot.setInsets(new RectangleInsets(10, 10, 0, 10), false);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setLegendItemToolTipGenerator(
            new StandardXYSeriesLabelGenerator("Legend {0}"));

    setXAixs(plot);
    setYAixs(plot);
}
 
Example 2
Source File: GsnChartJfreechart.java    From gsn with GNU General Public License v3.0 5 votes vote down vote up
public JFreeChart createChart(Collection<Data> datas) {
    TimeSeries t1 = new TimeSeries("S1");
    Iterator<Data> iter = datas.iterator() ; 
    Data data ;
    while (iter.hasNext()) {
        data = iter.next();
        t1.addOrUpdate(RegularTimePeriod.createInstance(Millisecond.class, new Date((Long)data.getP2()), TimeZone.getDefault()), data.getValue());
    }
    XYDataset dataset = new TimeSeriesCollection(t1);
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            null,
            null, 
            null, 
            dataset, 
            false,
            false, 
            false
    );
    chart.setAntiAlias(true);
    chart.setTextAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);
    //
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("No Data to Display");
    plot.setDomainGridlinesVisible(true);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setInsets(new RectangleInsets(5,14,0,5));
    //
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(ssdf);
    axis.setTickLabelFont(TICK_FONT);
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickLabelFont(TICK_FONT);
    //
    return chart;
}