Example usage for org.jfree.chart.plot XYPlot getRangeAxis

List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRangeAxis.

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

From source file:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;//from  www .  j av a  2 s.  c  om

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "f", // y-axis label
            dataset);

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    if (isMetric) {
        plot.getRangeAxis().setRange(0.0, 1.01);
    }
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setDrawSeriesLineAsPath(true);
        // set the default stroke for all series
        renderer.setAutoPopulateSeriesStroke(false);
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setSeriesPaint(1, new Color(24, 123, 58));
        renderer.setSeriesPaint(2, new Color(149, 201, 136));
        renderer.setSeriesPaint(3, new Color(1, 62, 29));
        renderer.setSeriesPaint(4, new Color(81, 176, 86));
        renderer.setSeriesPaint(5, new Color(0, 55, 122));
        renderer.setSeriesPaint(6, new Color(0, 92, 165));
    }

    return xyLineChart;
}

From source file:org.jfree.chart.demo.MarkerDemo1.java

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

    final JFreeChart chart = ChartFactory.createScatterPlot("Marker Demo 1", "X", "Y", data,
            PlotOrientation.VERTICAL, true, true, false);
    //    chart.getLegend().setAnchor(Legend.EAST);

    // customise...
    final XYPlot plot = chart.getXYPlot();
    plot.getRenderer().setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

    // set axis margins to allow space for marker labels...
    final DateAxis domainAxis = new DateAxis("Time");
    domainAxis.setUpperMargin(0.50);
    plot.setDomainAxis(domainAxis);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setUpperMargin(0.30);
    rangeAxis.setLowerMargin(0.50);

    // add a labelled marker for the bid start price...
    final Marker start = new ValueMarker(200.0);
    start.setPaint(Color.green);
    start.setLabel("Bid Start Price");
    start.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
    start.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addRangeMarker(start);

    // add a labelled marker for the target price...
    final Marker target = new ValueMarker(175.0);
    target.setPaint(Color.red);
    target.setLabel("Target Price");
    target.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    target.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(target);

    // add a labelled marker for the original closing time...
    final Hour hour = new Hour(2, new Day(22, 5, 2003));
    double millis = hour.getFirstMillisecond();
    final Marker originalEnd = new ValueMarker(millis);
    originalEnd.setPaint(Color.orange);
    originalEnd.setLabel("Original Close (02:00)");
    originalEnd.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    originalEnd.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    plot.addDomainMarker(originalEnd);

    // add a labelled marker for the current closing time...
    final Minute min = new Minute(15, hour);
    millis = min.getFirstMillisecond();
    final Marker currentEnd = new ValueMarker(millis);
    currentEnd.setPaint(Color.red);
    currentEnd.setLabel("Close Date (02:15)");
    currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    plot.addDomainMarker(currentEnd);

    // ****************************************************************************
    // * 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.             *
    // ****************************************************************************

    // label the best bid with an arrow and label...
    final Hour h = new Hour(2, new Day(22, 5, 2003));
    final Minute m = new Minute(10, h);
    millis = m.getFirstMillisecond();
    final CircleDrawer cd = new CircleDrawer(Color.red, new BasicStroke(1.0f), null);
    final XYAnnotation bestBid = new XYDrawableAnnotation(millis, 163.0, 11, 11, cd);
    plot.addAnnotation(bestBid);
    final XYPointerAnnotation pointer = new XYPointerAnnotation("Best Bid", millis, 163.0, 3.0 * Math.PI / 4.0);
    pointer.setBaseRadius(35.0);
    pointer.setTipRadius(10.0);
    pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
    pointer.setPaint(Color.blue);
    pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    plot.addAnnotation(pointer);

    return chart;

}

From source file:org.jgrasstools.gears.utils.chart.Scatter.java

public JFreeChart getChart() {
    if (chart == null) {
        chart = ChartFactory.createXYLineChart(title, // chart title
                xLabel,/*from   w  ww .ja  v  a 2s. c o  m*/
                // domain axis label
                yLabel,
                // range axis label
                dataset,
                // data
                PlotOrientation.VERTICAL,
                // orientation
                false,
                // include legend
                true,
                // tooltips?
                false
        // URLs?
        );

        XYPlot plot = (XYPlot) chart.getPlot();
        if (xLog) {
            LogAxis xAxis = new LogAxis("");
            xAxis.setBase(10);
            plot.setDomainAxis(xAxis);
        }
        if (yLog) {
            LogAxis yAxis = new LogAxis("");
            yAxis.setBase(10);
            plot.setRangeAxis(yAxis);
        }

        ValueAxis rangeAxis = plot.getRangeAxis();
        if (rangeAxis instanceof NumberAxis) {
            NumberAxis axis = (NumberAxis) rangeAxis;
            axis.setAutoRangeIncludesZero(false);
        }

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
        double x = 1.5;
        double w = x * 2;
        renderer.setSeriesShape(0, new Ellipse2D.Double(-x, x, w, w));
        setShapeLinesVisibility(plot);
    }
    return chart;
}

From source file:net.sf.maltcms.chromaui.annotations.PeakAnnotationRenderer.java

private void drawOutline(Shape entity, Graphics2D g2, Color fill, Color stroke, ChartPanel chartPanel,
        boolean scale, float alpha) {
    if (entity != null) {
        //System.out.println("Drawing entity with bbox: "+entity.getBounds2D());
        Shape savedClip = g2.getClip();
        Rectangle2D dataArea = chartPanel.getScreenDataArea();
        Color c = g2.getColor();/*from   w  w w  . ja va 2 s. c om*/
        Composite comp = g2.getComposite();
        g2.clip(dataArea);
        g2.setColor(fill);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        JFreeChart chart = chartPanel.getChart();
        XYPlot plot = (XYPlot) chart.getPlot();
        ValueAxis xAxis = plot.getDomainAxis();
        ValueAxis yAxis = plot.getRangeAxis();
        RectangleEdge xAxisEdge = plot.getDomainAxisEdge();
        RectangleEdge yAxisEdge = plot.getRangeAxisEdge();
        Rectangle2D entityBounds = entity.getBounds2D();
        double viewX = xAxis.valueToJava2D(entityBounds.getCenterX(), dataArea, xAxisEdge);
        double viewY = yAxis.valueToJava2D(entityBounds.getCenterY(), dataArea, yAxisEdge);
        double viewW = xAxis.lengthToJava2D(entityBounds.getWidth(), dataArea, xAxisEdge);
        double viewH = yAxis.lengthToJava2D(entityBounds.getHeight(), dataArea, yAxisEdge);
        PlotOrientation orientation = plot.getOrientation();

        //transform model to origin (0,0) in model coordinates
        AffineTransform toOrigin = AffineTransform.getTranslateInstance(-entityBounds.getCenterX(),
                -entityBounds.getCenterY());
        //transform from origin (0,0) to model location
        AffineTransform toModelLocation = AffineTransform.getTranslateInstance(entityBounds.getCenterX(),
                entityBounds.getCenterY());
        //transform from model scale to view scale
        double scaleX = viewW / entityBounds.getWidth();
        double scaleY = viewH / entityBounds.getHeight();
        Logger.getLogger(getClass().getName()).log(Level.FINE, "Scale x: {0} Scale y: {1}",
                new Object[] { scaleX, scaleY });
        AffineTransform toViewScale = AffineTransform.getScaleInstance(scaleX, scaleY);
        AffineTransform toViewLocation = AffineTransform.getTranslateInstance(viewX, viewY);
        AffineTransform flipTransform = AffineTransform.getScaleInstance(1.0f, -1.0f);
        AffineTransform modelToView = new AffineTransform(toOrigin);
        modelToView.preConcatenate(flipTransform);
        modelToView.preConcatenate(toViewScale);
        modelToView.preConcatenate(toViewLocation);
        //
        //            if (orientation == PlotOrientation.HORIZONTAL) {
        //                entity = ShapeUtilities.createTranslatedShape(entity, viewY,
        //                        viewX);
        //            } else if (orientation == PlotOrientation.VERTICAL) {
        //                entity = ShapeUtilities.createTranslatedShape(entity, viewX,
        //                        viewY);
        //            }
        FlatteningPathIterator iter = new FlatteningPathIterator(modelToView.createTransformedShape(entity)
                .getPathIterator(AffineTransform.getTranslateInstance(0, 0)), 5);
        Path2D.Float path = new Path2D.Float();
        path.append(iter, false);

        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        g2.fill(path);
        if (stroke != null) {
            g2.setColor(stroke);
            g2.draw(path);
        }
        g2.setComposite(comp);
        g2.setColor(c);
        g2.setClip(savedClip);
    } else {
        Logger.getLogger(getClass().getName()).info("Entity is null!");
    }
}

From source file:org.webcat.grader.graphs.HistogramChart.java

protected JFreeChart generateChart(WCChartTheme chartTheme) {
    JFreeChart chart = ChartFactory.createHistogram(null, xAxisLabel(), yAxisLabel(), intervalXYDataset(),
            orientation(), false, false, false);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setAutoPopulateSeriesOutlinePaint(true);
    renderer.setDrawBarOutline(true);/*from   ww w . j a  v a2s. com*/
    renderer.setShadowVisible(false);

    if (markValue != null) {
        plot.setDomainCrosshairVisible(true);
        plot.setDomainCrosshairValue(markValue.doubleValue());
        plot.setDomainCrosshairPaint(Color.red);
        plot.setDomainCrosshairStroke(MARKER_STROKE);
    }

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * calculates the correct height with multiple iterations Domain and Range axes need to share the
 * same unit (e.g. mm)/*from w w w  .  j a v  a2s.  com*/
 * 
 * @param myChart
 * @param copyToNewPanel
 * @param dataWidth width of data
 * @param axis for width calculation
 * @return
 */
public static double calcHeightToWidth(ChartPanel myChart, double chartWidth, double estimatedHeight,
        int iterations, boolean copyToNewPanel) {
    // if(myChart.getChartRenderingInfo()==null ||
    // myChart.getChartRenderingInfo().getChartArea()==null ||
    // myChart.getChartRenderingInfo().getChartArea().getWidth()==0)
    // result
    double height = estimatedHeight;
    double lastH = height;

    makeChartResizable(myChart);

    // paint on a ghost panel
    JPanel parent = (JPanel) myChart.getParent();
    JPanel p = copyToNewPanel ? new JPanel() : parent;
    if (copyToNewPanel)
        p.add(myChart, BorderLayout.CENTER);
    try {
        for (int i = 0; i < iterations; i++) {
            // paint on ghost panel with estimated height (if copy panel==true)
            myChart.setSize((int) chartWidth, (int) estimatedHeight);
            myChart.paintImmediately(myChart.getBounds());

            XYPlot plot = (XYPlot) myChart.getChart().getPlot();
            ChartRenderingInfo info = myChart.getChartRenderingInfo();
            Rectangle2D dataArea = info.getPlotInfo().getDataArea();
            Rectangle2D chartArea = info.getChartArea();

            // calc title space: will be added later to the right plot size
            double titleWidth = chartArea.getWidth() - dataArea.getWidth();
            double titleHeight = chartArea.getHeight() - dataArea.getHeight();

            // calc right plot size with axis dim.
            // real plot width is given by factor;
            double realPW = chartWidth - titleWidth;

            // ranges
            ValueAxis domainAxis = plot.getDomainAxis();
            org.jfree.data.Range x = domainAxis.getRange();
            ValueAxis rangeAxis = plot.getRangeAxis();
            org.jfree.data.Range y = rangeAxis.getRange();

            // real plot height can be calculated by
            double realPH = realPW / x.getLength() * y.getLength();

            // the real height
            height = realPH + titleHeight;

            // for next iteration
            estimatedHeight = height;
            if ((int) lastH == (int) height)
                break;
            else
                lastH = height;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (copyToNewPanel) {
        // reset to frame
        p.removeAll();
        parent.add(myChart);
    }

    return height;
}

From source file:subterranean.crimson.server.graphics.graphs.LineChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false);

    XYPlot plot = result.getXYPlot();
    plot.setDataset(1, new TimeSeriesCollection(s2));

    plot.setBackgroundPaint(new Color(0x000000));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);//www .ja v a2  s. c  om

    xaxis.setFixedAutoRange(160000.0); // 160 seconds
    xaxis.setVerticalTickLabels(false);

    ValueAxis yaxis = plot.getRangeAxis();

    yaxis.setAutoRange(true);
    yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return result;
}

From source file:loadmaprenderer.ChartTest.java

private JFreeChart makeChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Cost/Year Chart", "Year", "Cost", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLUE);
    plot.setRangeGridlinePaint(Color.BLUE);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);/*w ww. j  a  v a2 s  . c  o  m*/
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRange(rootPaneCheckingEnabled);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(rootPaneCheckingEnabled);
    return chart;
}

From source file:com.google.gwt.benchmarks.viewer.server.ReportImageServer.java

private JFreeChart createChart(String testName, Result result, String title, List<Result> comparativeResults) {

    // Find the maximum values across both axes for all of the results
    // (this chart's own results, plus all comparative results).
    ////from   w  ww .  j  a v  a  2 s . c  o m
    // This is a stop-gap solution that helps us compare different charts for
    // the same benchmark method (usually with different user agents) until we
    // get real comparative functionality in version two.

    double maxTime = 0;

    for (Result r : comparativeResults) {
        for (Trial t : r.getTrials()) {
            maxTime = Math.max(maxTime, t.getRunTimeMillis());
        }
    }

    // Determine the number of variables in this benchmark method
    List<Trial> trials = result.getTrials();
    Trial firstTrial = new Trial();
    int numVariables = 0;
    if (trials.size() > 0) {
        firstTrial = trials.get(0);
        numVariables = firstTrial.getVariables().size();
    }

    // Display the trial data.
    //
    // First, pick the domain and series variables for our graph.
    // Right now we only handle up to two "user" variables.
    // We set the domain variable to the be the one containing the most unique
    // values.
    // This might be easier if the results had meta information telling us
    // how many total variables there are, what types they are of, etc....

    String domainVariable = null;
    String seriesVariable = null;

    Map<String, Set<String>> variableValues = null;

    if (numVariables == 1) {
        domainVariable = firstTrial.getVariables().keySet().iterator().next();
    } else {
        // TODO(tobyr): Do something smarter, like allow the user to specify which
        // variables are domain and series, along with the variables which are
        // held constant.

        variableValues = new HashMap<String, Set<String>>();

        for (int i = 0; i < trials.size(); ++i) {
            Trial trial = trials.get(i);
            Map<String, String> variables = trial.getVariables();

            for (Map.Entry<String, String> entry : variables.entrySet()) {
                String variable = entry.getKey();
                Set<String> set = variableValues.get(variable);
                if (set == null) {
                    set = new TreeSet<String>();
                    variableValues.put(variable, set);
                }
                set.add(entry.getValue());
            }
        }

        TreeMap<Integer, List<String>> numValuesMap = new TreeMap<Integer, List<String>>();

        for (Map.Entry<String, Set<String>> entry : variableValues.entrySet()) {
            Integer numValues = new Integer(entry.getValue().size());
            List<String> variables = numValuesMap.get(numValues);
            if (variables == null) {
                variables = new ArrayList<String>();
                numValuesMap.put(numValues, variables);
            }
            variables.add(entry.getKey());
        }

        if (numValuesMap.values().size() > 0) {
            domainVariable = numValuesMap.get(numValuesMap.lastKey()).get(0);
            seriesVariable = numValuesMap.get(numValuesMap.firstKey()).get(0);
        }
    }

    String valueTitle = "time (ms)"; // This axis is time across all charts.

    if (numVariables == 0) {
        // Show a bar graph, with a single centered simple bar
        // 0 variables means there is only 1 trial
        DefaultCategoryDataset data = new DefaultCategoryDataset();
        data.addValue(firstTrial.getRunTimeMillis(), "result", "result");

        JFreeChart chart = ChartFactory.createBarChart(title, testName, valueTitle, data,
                PlotOrientation.VERTICAL, false, false, false);
        CategoryPlot p = chart.getCategoryPlot();
        ValueAxis axis = p.getRangeAxis();
        axis.setUpperBound(maxTime + maxTime * 0.1);
        return chart;
    } else if (numVariables == 1) {

        // Show a line graph with only 1 series
        // Or.... choose between a line graph and a bar graph depending upon
        // whether the type of the domain is numeric.

        XYSeriesCollection data = new XYSeriesCollection();

        XYSeries series = new XYSeries(domainVariable);

        for (Trial trial : trials) {
            double time = trial.getRunTimeMillis();
            String domainValue = trial.getVariables().get(domainVariable);
            series.add(Double.parseDouble(domainValue), time);
        }

        data.addSeries(series);

        JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data,
                PlotOrientation.VERTICAL, false, false, false);
        XYPlot plot = chart.getXYPlot();
        plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1);
        double maxDomainValue = getMaxValue(comparativeResults, domainVariable);
        plot.getDomainAxis().setUpperBound(maxDomainValue + maxDomainValue * 0.1);
        return chart;
    } else if (numVariables == 2) {
        // Show a line graph with two series
        XYSeriesCollection data = new XYSeriesCollection();

        Set<String> seriesValues = variableValues.get(seriesVariable);

        for (String seriesValue : seriesValues) {
            XYSeries series = new XYSeries(seriesValue);

            for (Trial trial : trials) {
                Map<String, String> variables = trial.getVariables();
                if (variables.get(seriesVariable).equals(seriesValue)) {
                    double time = trial.getRunTimeMillis();
                    String domainValue = trial.getVariables().get(domainVariable);
                    series.add(Double.parseDouble(domainValue), time);
                }
            }
            data.addSeries(series);
        }
        // TODO(tobyr) - Handle graphs above 2 variables

        JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data,
                PlotOrientation.VERTICAL, true, true, false);
        XYPlot plot = chart.getXYPlot();
        plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1);
        double maxDomainValue = getMaxValue(comparativeResults, domainVariable);
        plot.getDomainAxis().setUpperBound(maxDomainValue + maxDomainValue * 0.1);
        return chart;
    }

    throw new RuntimeException("The ReportImageServer is not yet able to "
            + "create charts for benchmarks with more than two variables.");

    // Sample JFreeChart code for creating certain charts:
    // Leaving this around until we can handle multivariate charts in dimensions
    // greater than two.

    // Code for creating a category data set - probably better with a bar chart
    // instead of line chart
    /*
     * DefaultCategoryDataset data = new DefaultCategoryDataset(); String series
     * = domainVariable;
     * 
     * for ( Iterator it = trials.iterator(); it.hasNext(); ) { Trial trial =
     * (Trial) it.next(); double time = trial.getRunTimeMillis(); String
     * domainValue = (String) trial.getVariables().get( domainVariable );
     * data.addValue( time, series, domainValue ); }
     * 
     * String title = ""; String categoryTitle = domainVariable; PlotOrientation
     * orientation = PlotOrientation.VERTICAL;
     * 
     * chart = ChartFactory.createLineChart( title, categoryTitle, valueTitle,
     * data, orientation, true, true, false );
     */

    /*
     * DefaultCategoryDataset data = new DefaultCategoryDataset(); String
     * series1 = "firefox"; String series2 = "ie";
     * 
     * data.addValue( 1.0, series1, "1024"); data.addValue( 2.0, series1,
     * "2048"); data.addValue( 4.0, series1, "4096"); data.addValue( 8.0,
     * series1, "8192");
     * 
     * data.addValue( 2.0, series2, "1024"); data.addValue( 4.0, series2,
     * "2048"); data.addValue( 8.0, series2, "4096"); data.addValue( 16.0,
     * series2,"8192");
     * 
     * String title = ""; String categoryTitle = "size"; PlotOrientation
     * orientation = PlotOrientation.VERTICAL;
     * 
     * chart = ChartFactory.createLineChart( title, categoryTitle, valueTitle,
     * data, orientation, true, true, false );
     */
}

From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java

@Override
public JFreeChart createXYLineChartToHoursOfDay(List<HoraDelDiaEstadistica> horasDelDia) {
    //Se obtiene el conjunto de datos
    XYDataset dataset = createDataForHoursOfDay(horasDelDia);

    JFreeChart chart = ChartFactory.createXYLineChart(TITLE_OF_XY_CHART, //Titulo del grafico
            DOMAIN_AXIS_LABEL_HOUR, //Nombre del Rango
            RANGE_AXIS_LABEL, //Nombre del dominio
            dataset, //conjunto de datos
            PlotOrientation.VERTICAL, //Orientacion del grafico
            true, //incluir leyendas
            true, false);//  www.j  ava2s  . c  om

    //Se pinta el fondo de blanco
    chart.setBackgroundPaint(Color.WHITE);

    //Se pintan el fondo del grafico de gris y las lineas de blanco
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);
    plot.setNoDataMessage(NO_DATA_TO_DISPLAY);

    //Se configura para que solo muestre nmeros enteros en el rango
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //Se configura para que solo muestre nmeros enteros en el dominio
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}