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

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

Introduction

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

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint for the grid lines plotted against the domain axis, and sends a PlotChangeEvent to all registered listeners.

Usage

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

protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart c = ChartFactory.createTimeSeriesChart(chartTitle, // "Legal & General Unit Trust Prices",
            domainLabel, rangeLabel, // "Date", "Price Per Unit",
            dataset, !legendPanelOn, true, false);

    c.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) c.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer;
        rr.setBaseShapesVisible(true);//w w w.ja v  a2s .  c  om
        rr.setBaseShapesFilled(true);
    }
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));

    //setXSummary(dataset) X is time;
    return c;

}

From source file:Demo.ScatterGraph.java

private JFreeChart CreateChart(int x, int y) {
    dataSet = new DefaultXYDataset();
    AddDataSet(x, y);//from   ww w  .j av  a 2 s. c  o m

    JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter", paraType_list.get(x),
            paraType_list.get(y), dataSet, PlotOrientation.VERTICAL, true, false, false);

    XYPlot plot = (XYPlot) jfreechart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer();
    xylineandshaperenderer.setSeriesOutlinePaint(0, Color.WHITE);
    xylineandshaperenderer.setUseOutlinePaint(true);
    xylineandshaperenderer.setSeriesPaint(0, Color.BLUE);

    return jfreechart;
}

From source file:domain.Grafica.java

public JFreeChart createChart(XYDataset dataset) {
    /*/*from  www.  j  a v  a 2 s  .  c  o  m*/
     ///*
     NumberAxis numberaxis = new NumberAxis("");
     numberaxis.setAutoRangeIncludesZero(false);
            
     DateAxis dateaxis = new DateAxis("");
            
     NumberAxis numberaxis1 = new NumberAxis("");
     numberaxis1.setAutoRangeIncludesZero(false);
            
     XYSplineRenderer xysplinerenderer = new XYSplineRenderer();
            
     XYPlot xyplot = new XYPlot(dataset, dateaxis, numberaxis1, xysplinerenderer);
     // xyplot.setBackgroundPaint(new Color(238, 242, 250));//
     // xyplot.setDomainGridlinePaint(new Color(255, 255, 255));
     // xyplot.setRangeGridlinePaint(new Color(238, 242, 250));
     xyplot.getRenderer().setSeriesPaint(0, Color.RED);
     xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
     XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
     renderer.setSeriesShapesVisible(0, true);//FIXME Dots
            
     //  xyplot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
     JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, xyplot, false);
     jfreechart.setBackgroundPaint(Color.white);
            
     DateAxis axis = (DateAxis) xyplot.getDomainAxis();
     axis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa"));
            
     xyplot.getRangeAxis().setUpperBound(maxPeso * 1.25);
     xyplot.getRangeAxis().setLowerBound(minPeso * 0.75);
     cargarImagen();
     // xyplot.setBackgroundImage(i);
     //jfreechart.setBackgroundImage(i);
     return jfreechart;
     */
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", // title
            "Fecha/Hora", // x-axis label
            "Pesos(Kg.)", // y-axis label
            dataset, // data
            false, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.GRAY);
    plot.setRangeGridlinePaint(Color.GRAY);
    /*         plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
     plot.setDomainCrosshairVisible(false);
     plot.setRangeCrosshairVisible(false);
     */
    plot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));

    XYItemRenderer r = plot.getRenderer();

    if (r instanceof XYLineAndShapeRenderer) {

        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
    }

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    // range.setAutoRangeIncludesZero(true);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss"));

    plot.getRangeAxis().setUpperBound(maxPeso * 1.25);
    plot.getRangeAxis().setLowerBound(minPeso * 0.75);

    return chart;

}

From source file:org.infoglue.deliver.util.charts.TimeSeriesDiagram.java

/**
 * Creates a chart./*from ww w. j a v  a2s.c om*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */

private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(header, axisXHeader, axisYHeader, dataset, true, true,
            false);

    chart.setBackgroundPaint(Color.white);

    LegendTitle legend = chart.getLegend();
    //legend.set .setDisplaySeriesShapes(true);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(UnitType.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer) {
        StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();

    if (this.timeGranulariry.equalsIgnoreCase("Week")) {
        DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat(this.dateFormat));
        axis.setTickUnit(unit);
        axis.setTickMarkPosition(DateTickMarkPosition.START);

        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    } else {
        axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
    }
    /*
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat(this.dateFormat));
      */
    return chart;

}

From source file:com.cs572.assignments.Project2.view.LineChartPanel.java

/**
 * Creates a chart./*from w w w  . j  av  a  2 s .  co 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("Expression Tree", // chart title
            "DataPoints", // x axis label
            "Output", // 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();
    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, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(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.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.rioproject.examples.hospital.ui.PatientStatsPanel.java

private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataSet, Color color) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataSet, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getRenderer().setSeriesPaint(0, color);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    ValueAxis yAxis = plot.getRangeAxis();
    yAxis.setRange(0, 150);//w  w  w.  ja va 2s  . c om
    ValueAxis xAxis = plot.getDomainAxis();
    xAxis.setAutoRange(true);
    xAxis.setFixedAutoRange(5 * MINUTE);
    return chart;
}

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

/**
 * Creates a chart./*  w  ww  .  ja v a2 s .c om*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    setXSummary(dataset);
    return chart;

}

From source file:presentationGui.GraphFrame.java

/**
 * Creates a chart.//  www .  java 2 s . com
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Comportamento Asintotico del throughput", // chart title
            "numero job", // x axis label
            "throughput", // 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();
    plot.setBackgroundPaint(Color.white);
    //    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.setStandardTickUnits(NumberAxis.createStandardTickUnits());*/
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:serverrobot.DynamicGraph.java

public JFreeChart createChart(XYDataset dataset, String pos, double minRange, double maxRange) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(pos, "Time (ms)", "Displacement", dataset, true,
            true, false);/* w  ww  .j  av a2  s .  co  m*/
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(232, 232, 232));
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.getRenderer().setSeriesPaint(0, Color.BLUE);
    plot.getRenderer().setSeriesPaint(1, Color.RED);

    ValueAxis axis = plot.getDomainAxis();
    //axis.setAutoRange(true);
    axis.setFixedAutoRange(20000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(minRange, maxRange);

    chart.setBackgroundPaint(Color.white);
    return chart;
}

From source file:Utils.GeneradorDeGraficas.java

public JFreeChart graficarCostos(DeterministaGeneral general, String unidad) {
    XYDataset dataset;/*from ww w .j a va  2s  .c o m*/

    dataset = createDatasetCosto(general, unidad);

    JFreeChart chart = ChartFactory.createXYLineChart("Anlisis de Costo de Inventario por " + unidad,
            "Cantidad de pedido", "Costo", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(4, black, true);
    renderer.setSeriesPaint(3, black, true);

    /* renderer.setShapesFilled(true);
     renderer.setShapesVisible(true);*/

    XYPlot plot2 = chart.getXYPlot();
    NumberAxis rangeAxis = (NumberAxis) plot2.getRangeAxis();
    rangeAxis.setAutoRange(false);

    rangeAxis.setUpperBound(general.calcularCostoGrafica(general.calcularCantidadOptimaOrdenar()) * 2);

    return chart;
}