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

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

Introduction

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

Prototype

public void setBackgroundPaint(Paint paint) 

Source Link

Document

Sets the background color of the plot area and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:web.diva.server.unused.ProfilePlotGenerator.java

/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings.//from   ww w. ja v a 2  s .  com
 *
 * @param title the chart title (<code>null</code> permitted).
 * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
 * @param dataset the dataset for the chart (<code>null</code> permitted).
 * @param orientation the plot orientation (horizontal or vertical)
 * (<code>null</code> NOT permitted).
 * @param legend a flag specifying whether or not a legend is required.
 * @param tooltips configure chart to generate tool tips?
 * @param urls configure chart to generate URLs?
 *
 * @return The chart.
 */
private JFreeChart createXYLineChart(String title, String[] columnIds, XYDataset dataset,
        PlotOrientation orientation, boolean legend, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    Font f = new Font("ARIAL", 1, 7);
    //        NumberAxis xAxis = new NumberAxis(xAxisLabel);
    //        xAxis.setAutoRangeIncludesZero(false);
    SymbolAxis xAxis = new SymbolAxis("", columnIds);
    xAxis.setAxisLineVisible(false);
    xAxis.setGridBandsVisible(false);
    xAxis.setVerticalTickLabels(true);
    xAxis.setVisible(true);

    xAxis.setTickLabelPaint(shadowColor);
    xAxis.setTickLabelFont(f);
    xAxis.setFixedDimension(51.0);

    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    xAxis.setTickUnit(new NumberTickUnit(1));
    xAxis.setRange(0, columnIds.length);
    //        NumberAxis yAxis = new NumberAxis(yAxisLabel);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setAxisLineVisible(false);
    yAxis.setTickLabelFont(f);
    yAxis.setTickLabelPaint(Color.BLUE);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseShapesVisible(false);
    renderer.setPaint(shadowColor);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);

    plot.setBackgroundPaint(Color.WHITE);

    plot.setDomainGridlinePaint(shadowColor);
    plot.setRangeGridlinePaint(shadowColor);
    plot.setOutlinePaint(Color.BLUE);
    //        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    //        plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    plot.setDomainAxis(xAxis);

    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;

}

From source file:CargarEntrenamiento.grafica2.java

public void grafica1() {
    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);/* ww  w. j av  a2 s . co  m*/
    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:CargarEntrenamiento.grafica2.java

public void iejmplo() {

    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);//  ww  w .  java2s  . c o  m
    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: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 a  2 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:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private XYPlot createPlotArea(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0));
    showCrosshairsOnAxes(plot);/*from  ww  w .ja v a  2s. com*/
    configureDomainAxis(plot);
    showGridlinesOnChart(plot);
    configureTimeAxis(plot);
    configureTitle(chart);
    addNotice(chart);
    return plot;
}

From source file:edu.unibonn.plotting.TimeSeriesPlotter_Sensors.java

private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset_centroids,
        ArrayList<Cluster_KMeans> clusters) {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false, //t
            true, //t
            false //f
    );/*from  w  w w  . j  av  a  2s. c  om*/

    ChartUtilities.applyCurrentTheme(chart);

    //chart.setBackgroundPaint(Color.white);

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

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    final XYItemRenderer renderer = plot.getRenderer();

    if (renderer instanceof StandardXYItemRenderer) {
        final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
        //rr.setPlotShapes(true);
        rr.setShapesFilled(true);
        rr.setItemLabelsVisible(true);
    }

    int temp_count = 0;

    //for (int i = 0; i < clusters.size(); i++)
    for (int i = 0; (i < 11) && (i < clusters.size()); i++) {
        Cluster_KMeans current_cluster = clusters.get(i);
        ArrayList<Sensor> member_time_series = current_cluster.getMembership();

        for (int j = 0; j < member_time_series.size(); j++) {
            renderer.setSeriesPaint(j + temp_count, getColor(i));
        }
        temp_count = temp_count + member_time_series.size();
    }

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

    //final ValueAxis axis_y = plot.getRangeAxis();
    //axis_y.setRange(0, 20);

    plot.setDataset(1, dataset_centroids);
    plot.setRenderer(1, new StandardXYItemRenderer());

    for (int i = 0; (i < clusters.size()); i++) {
        //plot.getRenderer(1).setSeriesPaint(i, getColor(i));
        plot.getRenderer(1).setSeriesPaint(i, Color.BLACK);
        plot.getRenderer(1).setSeriesStroke(i, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
    }

    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return chart;
}

From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java

public JFreeChart createMarinogram(ChartPlottingInfo cpi) {
    JFreeChart jchart = null;/*from  ww w  .j  a va  2  s  . co m*/
    if (!cpi.isShowAirTemperature() && !cpi.isShowWaterTemperature() && !cpi.isShowPressure()
            && !cpi.isShowWaveDirection() && !cpi.isShowWaveHeight() && !cpi.isShowCurrentDirection()
            && !cpi.isShowCurrentSpeed() && !cpi.isShowWindDirection() && !cpi.isShowWindSpeed()
            && !cpi.isShowDewpointTemperature()) {
        jchart = createEmptyChart(cpi);
        return jchart;
    }
    try {
        TimePeriod timePeriod = new TimePeriod(new Date(), MeteogramWrapper.SHORT_TERM_HOURS).adapt(3);

        // parse oceanforecast data from api.met.no
        Location location = new Location(cpi.getLongitude(), cpi.getLatitude());
        // The curve will not be shown if too many data points when setDrawSeriesLineAsPath(true) in render;
        OceanForecastParseScheme oceanForecastParseScheme = new OceanForecastParseScheme(timePeriod);
        ForecastParser forecastParser = new ForecastParser(oceanForecastParseScheme,
                OceanForecastAddressFactory.getURL(location).toString());
        // parse locationforcast data from api.met.no
        GenericDataModel locationForecastDataModel = null;
        GenericDataModel model = null;

        if (cpi.isShowAirTemperature() || cpi.isShowWaterTemperature() || cpi.isShowDewpointTemperature()) {
            MarinogramTemperaturePlot mp = new MarinogramTemperaturePlot(cpi.getWidth(), cpi.getWidth() / 4,
                    cpi.getTimezone(), cpi.getLanguage());
            totalPlotHeight += cpi.getWidth() / 4;
            mp.setDescription("Temperature Plot");
            mp.setShowAirTemp(cpi.isShowAirTemperature());
            mp.setShowSeaTemp(cpi.isShowWaterTemperature());
            mp.setShowDewTemp(cpi.isShowDewpointTemperature());
            locationForecastDataModel = MeteogramWrapper.getModel(location, timePeriod);
            mp.setLocationForecastDataModel(locationForecastDataModel);
            model = forecastParser.populateModelWithData();
            mp.setOceanForecastDataModel(model);
            this.addPlot(mp);

        }

        if (cpi.isShowCurrentDirection() || cpi.isShowCurrentSpeed()) {
            MarinogramCurrentPlot mp = new MarinogramCurrentPlot(cpi.getWidth(), cpi.getWidth() / 7,
                    cpi.getTimezone(), cpi.getLanguage());
            totalPlotHeight += cpi.getWidth() / 7;
            mp.setDescription("Current Plot");
            mp.setShowCurrentSpeed(cpi.isShowCurrentSpeed());
            mp.setShowCurrentDirection(cpi.isShowCurrentDirection());

            // extra check if model has no data
            if (model == null) {
                model = forecastParser.populateModelWithData();
            }
            mp.setOceanForecastDataModel(model);
            this.addPlot(mp);

        }

        if (cpi.isShowWaveDirection() || cpi.isShowWaveHeight()) {
            MarinogramWavePlot mp = new MarinogramWavePlot(cpi.getWidth(), cpi.getWidth() / 7,
                    cpi.getTimezone(), cpi.getLanguage());
            totalPlotHeight += cpi.getWidth() / 7;
            mp.setDescription("Wave Plot");
            mp.setShowWaveHeight(cpi.isShowWaveHeight());
            mp.setShowWaveDirection(cpi.isShowWaveDirection());

            // extra check if model has no data
            if (model == null) {
                model = forecastParser.populateModelWithData();
            }
            mp.setOceanForecastDataModel(model);
            this.addPlot(mp);

        }

        if (cpi.isShowPressure()) {
            MarinogramPressurePlot pressurePlot = new MarinogramPressurePlot(cpi.getWidth(), cpi.getWidth() / 7,
                    cpi.getTimezone(), cpi.getLanguage());
            totalPlotHeight += cpi.getWidth() / 7;
            pressurePlot.setShowPressure(cpi.isShowPressure());
            // extra check if locationForecastDataModel has no data
            if (locationForecastDataModel == null) {
                locationForecastDataModel = MeteogramWrapper.getModel(location, timePeriod);
            }
            pressurePlot.setLocationForecastDataModel(locationForecastDataModel);
            this.addPlot(pressurePlot);
        }

        if (cpi.isShowWindDirection() || cpi.isShowWindSpeed()) {
            MarinogramWindPlot mp = new MarinogramWindPlot(cpi.getWidth(), cpi.getWidth() / 7,
                    cpi.getTimezone(), cpi.getLanguage());
            totalPlotHeight += cpi.getWidth() / 7;
            mp.setDescription("Wind Plot");
            mp.setShowWindSpeed(cpi.isShowWindSpeed());
            mp.setShowWindDirection(cpi.isShowWindDirection());

            // extra check if model has no data
            if (model == null) {
                model = forecastParser.populateModelWithData();
            }
            locationForecastDataModel = MeteogramWrapper.getModel(location, timePeriod);
            mp.setLocationForecastDataModel(locationForecastDataModel);
            mp.setOceanForecastDataModel(model);
            this.addPlot(mp);

        }

        jchart = createJFreeChart("", this.getPlot(), this.getWidth());

    } catch (Exception e) {
        LogUtils.logException(logger, "Failure during marinogram generation with " + cpi.toString(), e);
        XYPlot plot = new XYPlot();
        plot.setBackgroundPaint(null);
        plot.setBackgroundImage(Symbols.getImage("/error.png"));
        jchart = createJFreeChart("", plot, this.getWidth());
    }
    return jchart;
}

From source file:Perfil_Deportivo.graficaEntrenamientoCargado.java

public graficaEntrenamientoCargado() {
    datos.removeAllSeries();/*from  w w  w  .j a v  a  2  s .com*/
    //sxy.add(x[0], y[0]);
    pesos = new double[EntrenamientoCargado.pesoentreno.length];
    fecha = new String[EntrenamientoCargado.fechaentreno.length];
    pesos = EntrenamientoCargado.pesoentreno;
    fecha = EntrenamientoCargado.fechaentreno;
    ///////////////77

    Date fechaDate = null;

    int n = pesos.length;
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < n; i++) {
        // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]);
        try {
            fechaDate = formato.parse(fecha[i]);
            calendar.setTime(fechaDate);
        } catch (ParseException ex) {

        }
        //  JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR));
        s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.YEAR)), pesos[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datos.addSeries(s1);
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fecha", "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:Perfil_Deportivo.graficaProgCargas.java

public graficaProgCargas() {
    datos.removeAllSeries();/*from   w w w  .j a va  2 s  . c o  m*/
    //sxy.add(x[0], y[0]);
    pesos = new double[Progresiones_cargas.pesoentreno.length];
    fecha = new String[Progresiones_cargas.fechaentreno.length];
    pesos = Progresiones_cargas.pesoentreno;
    fecha = Progresiones_cargas.fechaentreno;
    ///////////////77

    Date fechaDate = null;

    int n = pesos.length;
    Calendar calendar = Calendar.getInstance();

    for (int i = 0; i < n; i++) {
        // JOptionPane.showMessageDialog(null, "fecha tio:"+fecha[i]);
        try {
            fechaDate = formato.parse(fecha[i]);
            calendar.setTime(fechaDate);
        } catch (ParseException ex) {

        }
        //  JOptionPane.showMessageDialog(null, calendar.get(Calendar.DAY_OF_MONTH)+" "+calendar.get(Calendar.MONTH)+1+" "+ calendar.get(Calendar.YEAR));
        s1.add(new Day(calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.MONTH) + 1,
                calendar.get(Calendar.YEAR)), pesos[i]);
        // System.out.print(x[i]+"-"+i+" ");
    }
    datos.addSeries(s1);
    grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fecha", "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:edu.ucla.stat.SOCR.chart.ChartGenerator.java

protected JFreeChart createQQChart(String title, String xLabel, String yLabel, XYDataset dataset,
        String other) {//  w w w .j  ava  2 s. c  o  m

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xLabel, // x axis label
            yLabel, // 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);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    // renderer.setShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    //  renderer.setLinesVisible(false);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);

    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setUpperMargin(0);
    rangeAxis.setLowerMargin(0);

    // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    domainAxis.setUpperMargin(0);
    domainAxis.setLowerMargin(0);

    // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // OPTIONAL CUSTOMISATION COMPLETED.
    //setQQSummary(dataset);    // very confusing   
    return chart;

}