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

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

Introduction

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

Prototype

public void setRangeGridlinePaint(Paint paint) 

Source Link

Document

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

Usage

From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createBubbleChart(XYZDataset dataset) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    //        A renderer that draws a circle at each data point with a diameter that is
    //        determined by the z-value in the dataset (the renderer requires the dataset
    //        to be an instance of {@link XYZDataset}.
    XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }/*from  www.ja  va  2 s  .  c o m*/
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart("Bubble Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    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);

    return chart;
}

From source file:ac.kaist.ccs.presentation.CCSHubSelectionCost.java

/**
 * Creates a chart./*from ww w  . ja 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(title, // chart title
            "Number of Hubs", // x axis label
            "Cost for pipeline transportation \nfrom CO2 emission source node to hubs", // 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, 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());
    rangeAxis.setRange(minVal - (maxVal - minVal) * 0.05, maxVal + (maxVal - minVal) * 0.05);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:dpnm.netmsuite.plc.manager.frontend.graph.TimeSeriesChartDemo1.java

/**
 * Creates a chart./* w  ww. j  av  a 2  s  .c  o  m*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = null;
    if (this.graphType == 1) {
        chart = ChartFactory.createTimeSeriesChart(title, // title
                "Minute", // x-axis label
                "Packets/sec", // y-axis label
                dataset, // data
                true, // create legend?
                true, // generate tooltips?
                false // generate URLs?
        );
    } else if (this.graphType == 2) {
        chart = ChartFactory.createTimeSeriesChart(title, // title
                "Minute", // x-axis label
                "Bytes/sec", // y-axis label
                dataset, // data
                true, // create legend?
                true, // generate tooltips?
                false // generate URLs?
        );
    } else {
        chart = ChartFactory.createTimeSeriesChart(title, // title
                "Minute", // x-axis label
                "KBps", // y-axis label
                dataset, // data
                true, // create legend?
                true, // generate tooltips?
                false // generate URLs?
        );
    }

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.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 r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }

    DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));

    return chart;

}

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

/**
 * Creates a chart.//from   w  w  w  .j av  a 2s. com
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

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

    // get a reference to the plot for further customisation...
    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.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

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

    return chart;

}

From source file:com.googlecode.logVisualizer.chart.VerticalXYBarChartBuilder.java

private JFreeChart createChart(final IntervalXYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), xLable, false, yLable, dataset,
            PlotOrientation.VERTICAL, isIncludeLegend(), true, false);
    final XYPlot plot = (XYPlot) chart.getPlot();
    final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();

    double lastXValue = 0;
    if (dataset.getSeriesCount() > 0)
        lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1);

    plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue));
    plot.setNoDataMessage("No data available");
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    setBarShadowVisible(chart, false);/*from  w ww . j a  va  2s.co  m*/

    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (dataset.getSeriesCount() > 0)
        plot.getDomainAxis().setUpperBound(lastXValue);
    plot.getDomainAxis().setLowerBound(0);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setUpperMargin(0.1);

    return chart;
}

From source file:graficoComparacion.graficaCompa.java

public graficaCompa() {

    //sxy.add(x[0], y[0]);

    ///////////////
    /*   s1.add(new Month(4, 2001), 153.8);
       s1.add(new Month(5, 2001), 167.6);
       s1.add(new Month(6, 2001), 158.8);
       s1.add(new Month(7, 2001), 148.3);
       s1.add(new Month(8, 2001), 153.9);
       s1.add(new Month(9, 2001), 142.7);
       s1.add(new Month(10, 2001), 123.2); 
       //////////////////////////////////////
       datos.addSeries(s1);/*from  ww  w. j  ava 2 s .c o  m*/
    */
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fechas", "Peso", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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 r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

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

}

From source file:com.itemanalysis.jmetrik.graph.irt.IrtPlotPanel.java

private void createChart(String name, String title, String xLabel, String yLabel, double minScore,
        double maxScore) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // y axis label
            dataset, // data
            chartOrientation, // chart orientation
            showLegend, // include legend
            true, // tooltips
            false // urls
    );/*from  w w  w  .  ja va  2  s.co  m*/

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(false);
    renderer.setDrawOutlines(true);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    plot.getDomainAxis().setRange(minScore, maxScore);

    ChartPanel panel = new ChartPanel(chart);
    panel.getPopupMenu().addSeparator();
    panel.setPreferredSize(new Dimension(width, height));

    //        this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions

    chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0));
    charts.put(name, chart);

    JPanel subPanel = new JPanel();//additional panel needed to prevent gridlayout from stretching graph
    subPanel.add(panel);
    //        this.addJpgMenuItem(subPanel, panel.getPopupMenu());
    subPanel.setBackground(Color.WHITE);
    this.add(subPanel);

}

From source file:imc.graficaIMC.java

public void iejmplo() {
    TimeSeries s1 = new TimeSeries("Entrenamiento Actual");
    s1.add(new Month(2, 2001), 181.8);
    //s1.add(new Week(1, 1), null);
    s1.add(new Month(3, 2001), 167.3);
    s1.add(new Month(4, 2001), 153.8);
    s1.add(new Month(5, 2001), 167.6);
    s1.add(new Month(6, 2001), 158.8);
    s1.add(new Month(7, 2001), 148.3);
    s1.add(new Month(8, 2001), 153.9);
    s1.add(new Month(9, 2001), 142.7);
    s1.add(new Month(10, 2001), 123.2);
    s1.add(new Month(11, 2001), 131.8);
    s1.add(new Month(12, 2001), 139.6);
    s1.add(new Month(1, 2002), 142.9);
    s1.add(new Month(2, 2002), 138.7);
    s1.add(new Month(3, 2002), 137.3);
    s1.add(new Month(4, 2002), 143.9);
    s1.add(new Month(5, 2002), 139.8);
    s1.add(new Month(6, 2002), 137.0);
    s1.add(new Month(7, 2002), 132.8);

    TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
    s2.add(new Month(2, 2001), 129.6);
    s2.add(new Month(3, 2001), 123.2);
    s2.add(new Month(4, 2001), 117.2);
    s2.add(new Month(5, 2001), 124.1);
    s2.add(new Month(6, 2001), 122.6);
    s2.add(new Month(7, 2001), 119.2);
    s2.add(new Month(8, 2001), 116.5);
    s2.add(new Month(9, 2001), 112.7);
    s2.add(new Month(10, 2001), 101.5);
    s2.add(new Month(11, 2001), 106.1);
    s2.add(new Month(12, 2001), 110.3);
    s2.add(new Month(1, 2002), 111.7);
    s2.add(new Month(2, 2002), 111.0);
    s2.add(new Month(3, 2002), 109.6);
    s2.add(new Month(4, 2002), 113.2);
    s2.add(new Month(5, 2002), 111.6);
    s2.add(new Month(6, 2002), 108.8);
    s2.add(new Month(7, 2002), 101.6);

    TimeSeries s3 = new TimeSeries("andres2255");
    s3.add(new Month(2, 2001), 129.6);

    s3.add(new Month(10, 2001), 106.1);
    s3.add(new Month(1, 2002), 111.7);
    s3.add(new Month(2, 2002), 111.0);
    datos.addSeries(s1);//from   w  w w  . j  a  v  a2s.  c om
    datos.addSeries(s2);
    datos.addSeries(s3);

    grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true,
            false);
    /// 
    grafica.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) grafica.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 r = plot.getRenderer();
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
        renderer.setDrawSeriesLineAsPath(true);
    }

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

From source file:org.gumtree.vis.plot1d.Plot1D.java

private void createChart() {

    String title = null;/*from   ww  w  . j  a va 2  s . com*/
    String xTitle = null;
    String yTitle = null;
    if (dataset != null) {
        title = dataset.getTitle();
        xTitle = dataset.getXTitle() + (dataset.getXUnits() == null ? "" : " (" + dataset.getXUnits() + ")");
        yTitle = dataset.getYTitle() + (dataset.getYUnits() == null ? "" : " (" + dataset.getYUnits() + ")");
    } else {
        dataset = new XYErrorDataset();
    }
    chart = createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, false, true);
    chart.setBackgroundPaint(Color.WHITE);
    final LegendTitle legend = (LegendTitle) chart.getLegend();
    RectangleEdge legendPosition = RectangleEdge.BOTTOM;
    try {
        String legendProperty = "RectangleEdge." + System.getProperty("kuranda1D.legendPosition");
        if (RectangleEdge.BOTTOM.toString().equals(legendProperty))
            legendPosition = RectangleEdge.BOTTOM;
        else if (RectangleEdge.RIGHT.toString().equals(legendProperty))
            legendPosition = RectangleEdge.RIGHT;
        else if (RectangleEdge.LEFT.toString().equals(legendProperty))
            legendPosition = RectangleEdge.LEFT;
        else if (RectangleEdge.TOP.toString().equals(legendProperty))
            legendPosition = RectangleEdge.TOP;
    } catch (Exception e) {
        // TODO: handle exception
    }
    legend.setPosition(legendPosition);
    chart.setBorderVisible(true);
    //      ChartUtilities.applyCurrentTheme(chart);
    //      chartTheme.apply(chart);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainPannable(true);
    plot.setRangePannable(true);

    plot.setDomainGridlinesVisible(true);
    //        plot.setDomainCrosshairLockedOnData(true);
    //        plot.setDomainCrosshairVisible(true);
    plot.setRangeGridlinesVisible(true);
    //        plot.setRangeCrosshairLockedOnData(true);
    //        plot.setRangeCrosshairVisible(true);

    xAxis = plot.getDomainAxis();
    yAxis = plot.getRangeAxis();

    plot.setDataset(dataset);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        //         ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true);
        ((XYLineAndShapeRenderer) renderer).setBaseShapesFilled(true);
    }
    //      XYErrorRenderer errorRenderer = (XYErrorRenderer) chart.getXYPlot().getRenderer();
    //      errorRenderer.setDrawXError(true);
    //        StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    //        renderer.setPlotLines(true);
    //        renderer.setBaseShapesVisible(true);

    chart.fireChartChanged();
}

From source file:daylightchart.daylightchart.chart.DaylightChart.java

/**
 * Creates the daylight chart./*from   w w w. j  a  v a2s .  c  om*/
 */
private void createChart(final Options options) {

    setBackgroundPaint(Color.white);

    final XYPlot plot = getXYPlot();

    // Set the first renderer, so that the grid lines can be shown
    plot.setRenderer(new StandardXYItemRenderer());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setBackgroundPaint(ChartConfiguration.nightColor);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    createMonthsAxis(plot);
    createHoursAxis(plot);

    // Create a marker region for daylight savings time
    if (riseSetData.usesDaylightTime()) {
        createDSTMarker(plot);
    }

    createBandsInPlot(plot);

    ChartOrientation chartOrientation = ChartOrientation.STANDARD;
    if (options != null) {
        chartOrientation = options.getChartOrientation();
    }
    adjustForChartOrientation(chartOrientation);

    final Options optionsNotNull;
    if (options == null) {
        optionsNotNull = new Options();
    } else {
        optionsNotNull = options;
    }
    createTitles(optionsNotNull.getChartOptions(), ChartConfiguration.chartFont.deriveFont(Font.BOLD, 18));

    createLegend(optionsNotNull, ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12));

}