Example usage for org.jfree.chart ChartFactory createXYLineChart

List of usage examples for org.jfree.chart ChartFactory createXYLineChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createXYLineChart.

Prototype

public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a line chart (based on an XYDataset ) with default settings.

Usage

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java

private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset,
        String other) {/*from  w w  w  .ja  v a2  s. c  o m*/

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    //plot.setNoDataMessage("No data available");

    // customise the range axis...

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //rangeAxis.setAutoRange(false);   
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    // domainAxis.setAutoRange(false);   
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // customise the renderer...
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseLinesVisible(false);
    renderer.setDrawOutlines(true);
    renderer.setBaseShapesFilled(true);
    renderer.setUseFillPaint(true);
    //renderer.setFillPaint(Color.white);

    if (other.toLowerCase().indexOf("noshape") != -1) {
        renderer.setBaseShapesVisible(false);
        renderer.setBaseLinesVisible(true);
    }

    if (other.toLowerCase().indexOf("excludeszero") != -1) {
        rangeAxis.setAutoRangeIncludesZero(false);
        domainAxis.setAutoRangeIncludesZero(false);
    }

    return chart;
}

From source file:dla_franctal.LineChart.java

/**
 * Creates a chart./*from www  . j a va 2  s .  c o m*/
 * 
 * @param dataset  the data for the chart.
 * @param yS 
 * @param xS 
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String xS, String yS) {

    JFreeChart chart = null;

    if (xS == null && yS == null) {
        // create the chart...
        chart = ChartFactory.createXYLineChart("", // chart title
                "DLA_particles", // x axis label
                "DLA_particles/DLA_BB_Area", // y axis label
                dataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, // tooltips
                false // urls
        );
    } else {
        chart = ChartFactory.createXYLineChart("", // chart title
                xS, // x axis label
                yS, // y axis label
                dataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, // tooltips
                false // urls
        );
    }

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    //        final XYPlot plot = chart.getXYPlot();
    //       // int seriesCount = plot.getSeriesCount();
    //        for (int i = 0; i < seriesCount; i++) {
    //           plot.getRenderer().setSeriesStroke(i, new BasicStroke(
    //                   2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
    //                   1.0f, new float[] {6.0f, 6.0f}, 0.0f
    //               ));
    //        }
    //plot.setBackgroundPaint(Color.lightGray);
    //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    //plot.setDomainGridlinePaint(Color.white);
    //plot.setRangeGridlinePaint(Color.white);

    //final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    //renderer.setSeriesLinesVisible(0, false);
    //renderer.setSeriesShapesVisible(1, false);
    //plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    //        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    //        rangeAxis.setRange(0.0, 1.0);
    //rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.*/

    return chart;

}

From source file:ca.nengo.plot.impl.DefaultPlotter.java

/**
 * @see ca.nengo.plot.Plotter#doPlot(java.util.List, java.util.List, java.lang.String)
 *///from www  . j ava2s.c o  m
public void doPlot(List<TimeSeries> series, List<SpikePattern> patterns, String title) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", null, PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();

    //we will change the legend to show one item per series/pattern (rather than dimension/neuron)
    LegendItemCollection revisedItems = new LegendItemCollection();
    int legendItemIndex = 0;

    int i = 0;
    for (; series != null && i < series.size(); i++) {
        plot.setDataset(i, getDataset(series.get(i)));
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setPaint(getColor(i));
        plot.setRenderer(i, renderer);

        String seriesName = series.get(i).getName();
        if (seriesName == null)
            seriesName = "Time Series " + i;

        revisedItems.add(getCopy(plot.getLegendItems().get(legendItemIndex), seriesName));
        legendItemIndex += series.get(i).getDimension();
    }

    for (int j = 0; patterns != null && j < patterns.size(); j++) {
        int index = i + j;
        plot.setDataset(index, getDataset(patterns.get(j)));
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
        configSpikeRenderer(renderer);
        renderer.setPaint(getColor(j));
        plot.setRenderer(index, renderer);

        revisedItems.add(getCopy(plot.getLegendItems().get(legendItemIndex), "Spike Pattern " + j));
        legendItemIndex += patterns.get(j).getNumNeurons();
    }

    plot.setFixedLegendItems(revisedItems);
    showChart(chart, title);
}

From source file:edu.ucla.stat.SOCR.applications.demo.StockSimulationApplication.java

void updateGraph() {
    //System.out.println("UpdateGraph get called")
    calculate();//w w  w.  j a v  a 2s . c  o  m

    XYSeriesCollection ds = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            ds, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    chart.setBackgroundPaint(Color.white);
    XYPlot subplot1 = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) subplot1.getRenderer();

    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.blue);
    renderer1.setSeriesPaint(2, Color.green);
    renderer1.setSeriesPaint(3, Color.gray);

    /* Shape shape = renderer1.getBaseShape();
     renderer1.setSeriesShape(2, shape);
     renderer1.setSeriesShape(3, shape);*/
    renderer1.setBaseLinesVisible(true);
    renderer1.setBaseShapesVisible(true);
    renderer1.setBaseShapesFilled(true);

    chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y));

    upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel),
            new JScrollPane(chartPanel));

    this.getMainPanel().removeAll();
    this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    this.getMainPanel().validate();
    //  getRecordTable().setText("Any Explaination goes here.");

    //
}

From source file:Methods.CalculusNewtonRaphson.java

public static ChartPanel createChartNewtonRapson(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set 

    datasetPointsNewtonRapson();//from  w  ww  . j av  a2s. c om
    JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction,
            PlotOrientation.VERTICAL, true, true, false);//creating a object table wich takes the methods arguments as a dataset

    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table

    plot.setDataset(1, datasetPoints);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    plot.setRenderer(1, renderer);

    return new ChartPanel(chart);

}

From source file:userinterface.graph.Graph.java

/**
 * Initialises the GraphModel's series and canvas list. Also starts off the
 * graph update timer (one per chart)./*w ww  . ja va 2 s  .c om*/
 * 
 * @param title
 *            Title of the graph.
 */
public Graph(String title) {
    super(ChartFactory.createXYLineChart(title, "X", "Y", new XYSeriesCollection(), PlotOrientation.VERTICAL,
            true, true, false));

    graphCache = new HashMap<SeriesKey, LinkedList<XYDataItem>>();
    keyToSeries = new HashMap<SeriesKey, XYSeries>();
    keyToGraphSeries = new HashMap<SeriesKey, SeriesSettings>();
    graphTitle = new MultipleLineStringSetting("title", title, "The main title heading for the chart.", this,
            false);
    titleFont = new FontColorSetting("title font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 14), Color.black),
            "The font for the chart's title", this, false);
    legendVisible = new BooleanSetting("legend visible?", new Boolean(true),
            "Should the legend, which displays all of the series headings, be displayed?", this, false);

    String[] choices = { "Left", "Right", "Bottom", "Top" };
    legendPosition = new ChoiceSetting("legend position", choices, choices[RIGHT], "The position of the legend",
            this, false);
    legendFont = new FontColorSetting("legend font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 11), Color.black), "The font for the legend",
            this, false);

    // Some easy references
    chart = super.getChart();
    plot = chart.getXYPlot();
    plot.setBackgroundPaint((Paint) Color.white);
    seriesCollection = (XYSeriesCollection) plot.getDataset();

    xAxisSettings = new AxisSettings("X", true, this);
    yAxisSettings = new AxisSettings("Y", false, this);

    xAxisSettings.addObserver(this);
    yAxisSettings.addObserver(this);

    displaySettings = new DisplaySettings(this);
    displaySettings.addObserver(this);

    seriesList = new SeriesSettingsList(this);

    // create a regular XY line chart
    XYItemRenderer r = plot.getRenderer();
    // if possible, try to match the old grapher
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setAutoPopulateSeriesPaint(true);
        renderer.setAutoPopulateSeriesShape(true);
    }

    plot.setDrawingSupplier(new DefaultDrawingSupplier(SeriesSettings.DEFAULT_PAINTS,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, SeriesSettings.DEFAULT_SHAPES));

    super.setPopupMenu(null);

    /* Make sure the graph resembles its default settings. */
    updateGraph();

    // schedule a periodic timer for graph updates
    new java.util.Timer().scheduleAtFixedRate(new GraphUpdateTask(), 0, // start now
            updateInterval);
}

From source file:edu.pdi2.visual.ThresholdSignature.java

private void initGUI(int cantBands) {
    try {//  w  w  w  . ja  v a2  s. co m
        {
            getContentPane().setLayout(null);
            this.setPreferredSize(new java.awt.Dimension(359, 457));
            {
                for (int i = 0; i < cantBands; ++i) {
                    scrollbars[i] = new JScrollBar();
                    getContentPane().add(scrollbars[i]);
                    scrollbars[i].setBounds(50 * i + 20, 42, 17, 71);
                    scrollbars[i].setValue(INITIAL_DEVIATION);

                    final Integer index = new Integer(i);
                    scrollbars[i].addAdjustmentListener(new AdjustmentListener() {
                        public void adjustmentValueChanged(AdjustmentEvent evt) {
                            evt.setSource(new Integer(index));
                            scrollBarAdjustmentValueChanged(evt);
                        }

                    });

                }
            }
            // {
            // jScrollBar1 = new JScrollBar();
            // getContentPane().add(jScrollBar1);
            // jScrollBar1.setBounds(20, 42, 17, 71);
            // jScrollBar1.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar1AdjustmentValueChanged(evt);
            // }
            // });
            // }
            {
                for (int i = 0; i < cantBands; ++i) {
                    bandLabels[i] = new JLabel();
                    getContentPane().add(bandLabels[i]);
                    bandLabels[i].setText("Band " + i);
                    bandLabels[i].setBounds(50 * i + 12, 23, 33, 14);

                }
            }

            // {
            // jLabel1 = new JLabel();
            // getContentPane().add(jLabel1);
            // jLabel1.setText("Band 1");
            // jLabel1.setBounds(12, 23, 33, 14);
            // }
            {
                signatureG = ChartFactory.createXYLineChart("Signature ", "Bands", "Valory", null,
                        PlotOrientation.VERTICAL, true, true, false);
                chartpanel = new ChartPanel(signatureG);
                getContentPane().add(chartpanel);
                chartpanel.setBorder(BorderFactory.createTitledBorder(""));
                chartpanel.setBounds(20, 157, 45 * cantBands + 20, 210);
            }
            // {
            // jLabel2 = new JLabel();
            // getContentPane().add(jLabel2);
            // jLabel2.setText("Band 2");
            // jLabel2.setBounds(62, 23, 33, 14);
            // }
            // {
            // jScrollBar2 = new JScrollBar();
            // getContentPane().add(jScrollBar2);
            // jScrollBar2.setBounds(70, 42, 17, 71);
            // jScrollBar2.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar2AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel3 = new JLabel();
            // getContentPane().add(jLabel3);
            // jLabel3.setText("Band 3");
            // jLabel3.setBounds(112, 23, 33, 14);
            // }
            // {
            // jScrollBar3 = new JScrollBar();
            // getContentPane().add(jScrollBar3);
            // jScrollBar3.setBounds(120, 42, 17, 71);
            // jScrollBar3.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar3AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel4 = new JLabel();
            // getContentPane().add(jLabel4);
            // jLabel4.setText("Band 4");
            // jLabel4.setBounds(162, 23, 33, 14);
            // }
            // {
            // jScrollBar4 = new JScrollBar();
            // getContentPane().add(jScrollBar4);
            // jScrollBar4.setBounds(170, 42, 17, 71);
            // jScrollBar4.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar4AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel5 = new JLabel();
            // getContentPane().add(jLabel5);
            // jLabel5.setText("Band 5");
            // jLabel5.setBounds(212, 23, 33, 14);
            // }
            // {
            // jScrollBar5 = new JScrollBar();
            // getContentPane().add(jScrollBar5);
            // jScrollBar5.setBounds(220, 42, 17, 71);
            // jScrollBar5.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar5AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel6 = new JLabel();
            // getContentPane().add(jLabel6);
            // jLabel6.setText("Band 6");
            // jLabel6.setBounds(262, 23, 33, 14);
            // }
            // {
            // jScrollBar6 = new JScrollBar();
            // getContentPane().add(jScrollBar6);
            // jScrollBar6.setBounds(270, 42, 17, 71);
            // jScrollBar6.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar6AdjustmentValueChanged(evt);
            // }
            // });
            // }
            // {
            // jLabel7 = new JLabel();
            // getContentPane().add(jLabel7);
            // jLabel7.setText("Band 7");
            // jLabel7.setBounds(312, 23, 33, 14);
            // }
            // {
            // jScrollBar7 = new JScrollBar();
            // getContentPane().add(jScrollBar7);
            // jScrollBar7.setBounds(320, 42, 17, 71);
            // jScrollBar7.addAdjustmentListener(new AdjustmentListener() {
            // public void adjustmentValueChanged(AdjustmentEvent evt) {
            // jScrollBar7AdjustmentValueChanged(evt);
            // }
            // });
            // }
            {
                for (int i = 0; i < cantBands; ++i) {
                    valueLabels[i] = new JLabel();
                    getContentPane().add(valueLabels[i]);
                    valueLabels[i].setText(String.valueOf(INITIAL_DEVIATION));
                    valueLabels[i].setBounds(50 * i + 20, 119, 33, 19);

                }
            }
            // {
            // jLabel8 = new JLabel();
            // getContentPane().add(jLabel8);
            // jLabel8.setBounds(20, 119, 33, 19);
            // jLabel8.setText("0");
            // }
            // {
            // jLabel9 = new JLabel();
            // getContentPane().add(jLabel9);
            // jLabel9.setText("0");
            // jLabel9.setBounds(70, 119, 33, 19);
            // }
            // {
            // jLabel10 = new JLabel();
            // getContentPane().add(jLabel10);
            // jLabel10.setText("0");
            // jLabel10.setBounds(120, 119, 33, 19);
            // }
            // {
            // jLabel11 = new JLabel();
            // getContentPane().add(jLabel11);
            // jLabel11.setText("0");
            // jLabel11.setBounds(170, 119, 33, 19);
            // }
            // {
            // jLabel12 = new JLabel();
            // getContentPane().add(jLabel12);
            // jLabel12.setText("0");
            // jLabel12.setBounds(220, 119, 33, 19);
            // }
            // {
            // jLabel13 = new JLabel();
            // getContentPane().add(jLabel13);
            // jLabel13.setText("0");
            // jLabel13.setBounds(270, 119, 33, 19);
            // }
            // {
            // jLabel14 = new JLabel();
            // getContentPane().add(jLabel14);
            // jLabel14.setText("0");
            // jLabel14.setBounds(320, 119, 33, 19);
            // }
            {
                btCancel = new JButton();
                getContentPane().add(btCancel);
                btCancel.setText("Cancel");
                btCancel.setBounds(51 * cantBands - 75, 379, 75, 25);
                btCancel.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        btCancelMouseClicked(evt);
                    }
                });
            }
            {
                btOk = new JButton();
                getContentPane().add(btOk);
                btOk.setText("Generate");
                btOk.setBounds(51 * cantBands - 155, 379, 75, 25);
                btOk.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        btOkMouseClicked(evt);
                    }
                });
            }
        }
        this.setSize(51 * cantBands + 40, 457);
        this.setResizable(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

/**
 * This will plot the data as series of data[1], data[2], data[3]....
 * //  ww  w.j  a  v a  2  s  .c  o  m
 * @param data
 * @param names
 * @param title
 * @param xlabel
 * @param ylabel
 * @return
 */
public static JFreeChart getPlot(float[][] data, String[] names, String title, String xlabel, String ylabel,
        boolean showPoints, boolean showLines) {

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            xlabel, // X-Axis label
            ylabel, // Y-Axis label
            new XYSeriesCollection(), // Dataset
            PlotOrientation.VERTICAL, true, // Show legend
            true, true);

    for (int i = 0; i < data.length; i++) {
        float[] xData = getXDataFloat(data[i].length);
        XYSeriesCollection datCol = getCollection(xData, data[i],
                ((names == null) || (names[i] == null) ? "" : names[i]));

        // Add the series
        chart.getXYPlot().setDataset(i, datCol);

        // Set the rendering
        XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(showLines, showPoints);
        rend1.setSeriesPaint(0, getPlotColor(i));
        chart.getXYPlot().setRenderer(i, rend1);
    }
    return chart;
}

From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java

/**
 * Creates a chart./*  w  ww  .j a  v  a 2 s  .  c o  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Proteus III Compass Measurements", // chart title
            "Time (s)", // x axis label
            "Angle (degrees)", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customization...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    //    plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setRange(new Range(0, 140));

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    // change the auto tick unit selection to integer units only...
    //        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //rangeAxis.setRange(new Range(-Math.PI, Math.PI));
    rangeAxis.setRange(new Range(-180, 180));

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java

protected JFreeChart createLegend(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // url
    );/*  ww  w.j  a  v  a  2s  .  c  om*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseLinesVisible(false);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    plot.setRenderer(renderer);
    return chart;

}