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

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

Introduction

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

Prototype

public void setDomainCrosshairVisible(boolean flag) 

Source Link

Document

Sets the flag indicating whether or not the domain crosshair is visible and, if the flag changes, sends a PlotChangeEvent to all registered listeners.

Usage

From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java

public void GenerateMassCalibrationRTMap() throws IOException {
    String pngfile = FilenameUtils.getFullPath(ScanCollectionName) + "/"
            + FilenameUtils.getBaseName(ScanCollectionName) + "_masscaliRT.png";
    XYSeries series = new XYSeries("PSM");
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    LoessInterpolator loessInterpolator = new LoessInterpolator(0.75, //bandwidth,
            2//robustnessIters
    );//from  w w  w  . j  a  v a  2 s  .  c  o m

    for (PSM psm : this.IDsummary.PSMList.values()) {
        float ppm = InstrumentParameter.CalcSignedPPM(psm.ObserPrecursorMass, psm.NeutralPepMass);
        series.add(new XYDataItem(psm.RetentionTime, ppm));
    }
    double x[] = new double[IDsummary.PSMList.size()];
    double y[] = new double[x.length];
    double currentmin = 0f;
    for (int i = 0; i < series.getItemCount(); i++) {
        x[i] = (double) series.getX(i);
        if (x[i] <= currentmin) {
            x[i] = currentmin + 0.0001f;
        }
        currentmin = x[i];
        y[i] = (double) series.getY(i);
    }

    Masscalibrationfunction = loessInterpolator.interpolate(x, y);
    XYSeries smoothline = new XYSeries("Loess Regression");

    double xvalue = x[0];

    while (xvalue < x[x.length - 1]) {
        smoothline.add(xvalue, Masscalibrationfunction.value(xvalue));
        xvalue += 0.05d;
    }
    xySeriesCollection.addSeries(smoothline);
    xySeriesCollection.addSeries(series);

    JFreeChart chart = ChartFactory.createScatterPlot("Mass calibration", "RT", "Mass error (ppm)",
            xySeriesCollection, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.setDomainCrosshairVisible(true);
    xyPlot.setRangeCrosshairVisible(true);

    XYItemRenderer renderer = xyPlot.getRenderer();
    renderer.setSeriesPaint(1, Color.blue);
    renderer.setSeriesPaint(0, Color.BLACK);
    renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
    renderer.setSeriesStroke(1, new BasicStroke(1.0f));
    xyPlot.setBackgroundPaint(Color.white);
    ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}

From source file:mineria.UI.java

public UI() {
    this.setLayout(new GridBagLayout());

    Label lblnodatos = new Label("NoDatos: ");
    Label label = new Label("BD: ");
    JTextField filename = new JTextField("/Users/eduardomartinez/Documents/mineria/representacion.txt");
    JTextField nodatos = new JTextField();
    nodatos.setText("500");

    JTextField funcion = new JTextField("6");
    JTextField individuos = new JTextField("200");
    JTextField enteros = new JTextField("1");
    JTextField decimales = new JTextField("40");
    JTextField variables = new JTextField("6");
    JTextField Pc = new JTextField("0.9");
    JTextField Pm = new JTextField("0.01");
    JTextField generaciones = new JTextField("100");
    JTextField minimiza = new JTextField("0");

    Label lblfuncion = new Label("funcion: ");
    Label lblindividuos = new Label("individuos: ");
    Label lblenteros = new Label("enteros: ");
    Label lbldecimales = new Label("decimales: ");
    Label lblvariables = new Label("variables: ");
    Label lblpc = new Label("Pc: ");
    Label lblpm = new Label("Pm: ");
    Label lblgeneraciones = new Label("generaciones: ");
    Label lblminimiza = new Label("[0 Min/1 Max] : ");

    /*//w  w  w .  ja va 2  s. co  m
    FN=funcion;
    N =individuos;
    E =bits_enteros;
    D =bits_decimales;
    V =variables;
    Pc=porcentaje_cruza;
    Pm=porcentaje_muta;
    G =generaciones;
    MM=minimiza;
    */

    JButton openBtn = new JButton("Open BD");
    JButton ejecutarEGA = new JButton("Ejecutar EGA");
    JTextField resultado = new JTextField();
    Label fitness = new Label("fitness: ");

    XYSeriesCollection datosSerie = new XYSeriesCollection();

    AGF agf = new AGF(2);
    EGA ega = new EGA();

    JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot", // chart title
            "X", // x axis label
            "Y", // y axis label
            datosSerie, // data  ***-----PROBLEM------***
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // create and display a frame...
    ChartPanel panelChart = new ChartPanel(chart);

    //leer BD
    openBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            //datosSerie.removeAllSeries();
            if (filename.getText().length() > 0) {
                agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText()));

                createDataset(datosSerie, agf.data, "Datos");
                chart.fireChartChanged();
            } else {
                JFileChooser openFile = new JFileChooser();
                int rVal = openFile.showOpenDialog(null);
                if (rVal == JFileChooser.APPROVE_OPTION) {
                    filename.setText(openFile.getSelectedFile().getAbsolutePath());
                    agf.LeerDatos(filename.getText(), Integer.parseInt(nodatos.getText()));
                    //createDataset(datosSerie, agf.data, "Datos");
                    //chart.fireChartChanged();
                }
                if (rVal == JFileChooser.CANCEL_OPTION) {
                    filename.setText("");
                    //dir.setText("");
                }
            }
        }
    });

    ejecutarEGA.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            //datosSerie.removeAllSeries();
            if (datosSerie.getSeriesCount() > 1)
                datosSerie.removeSeries(1);

            int fn = Integer.parseInt(funcion.getText());
            int n = Integer.parseInt(individuos.getText());
            int e = Integer.parseInt(enteros.getText());
            int d = Integer.parseInt(decimales.getText());
            int v = Integer.parseInt(variables.getText());
            double pc = Double.parseDouble(Pc.getText());
            double pm = Double.parseDouble(Pm.getText());
            int g = Integer.parseInt(generaciones.getText());
            int mm = Integer.parseInt(minimiza.getText());

            ega.setParams(fn, n, e, d, v, pc, pm, g, mm);

            Resultado res = ega.ejecutarAlgoritmoGenetico(agf);

            resultado.setText(String.valueOf(res.getFitnessSemental()));

            res.creaArchivo();
            createDataset(datosSerie, res.getFenotipoSemental(), "Centros");

            Shape cross = ShapeUtilities.createDiagonalCross(5, 1);
            XYPlot xyPlot = (XYPlot) chart.getPlot();
            xyPlot.setDomainCrosshairVisible(true);
            xyPlot.setRangeCrosshairVisible(true);
            XYItemRenderer renderer = xyPlot.getRenderer();
            renderer.setSeriesShape(1, cross);
            renderer.setSeriesPaint(1, Color.blue);

            chart.fireChartChanged();

        }
    });
    //ejecutar AG

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblnodatos, gbc);

    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(nodatos, gbc);

    gbc.gridx = 2;
    gbc.gridy = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(filename, gbc);

    gbc.gridx = 3;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(openBtn, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(fitness, gbc);

    gbc.gridx = 3;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(resultado, gbc);

    gbc.gridx = 2;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(ejecutarEGA, gbc);

    //-----------------PARAMETROS
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblfuncion, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(funcion, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblindividuos, gbc);

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(individuos, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblenteros, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(enteros, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lbldecimales, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(decimales, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblvariables, gbc);

    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(variables, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblpc, gbc);

    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(Pc, gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblpm, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(Pm, gbc);

    gbc.gridx = 0;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblgeneraciones, gbc);

    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(generaciones, gbc);

    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(lblminimiza, gbc);

    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    this.add(minimiza, gbc);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 9;
    gbc.gridheight = 2;
    gbc.gridwidth = 4;
    this.add(panelChart, gbc);

    this.setTitle("File Chooser");

    this.pack();
}

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

private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Sensors", "Time", "Erlang", dataset, false,
            true, false);//from  ww w  .  j a v a2s .c o  m

    chart.setBackgroundPaint(Color.white);

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

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    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);
    }

    final DateAxis axis = (DateAxis) plot.getDomainAxis();
    axis.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy hh:mm"));

    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 a va  2s.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: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);//from   ww w  . jav a  2  s  .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:Perfil_Deportivo.graficaEntrenamientoCargado.java

public graficaEntrenamientoCargado() {
    datos.removeAllSeries();//from   ww  w . ja v  a 2s  .  c o  m
    //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 va2s  .  co 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:imc.graficaIMC.java

public graficaIMC() {
    TimeSeries s1 = new TimeSeries("REGISTRO DE IMC ");
    datos.removeAllSeries();/*from  w ww.j  a  v  a  2 s .  c  o  m*/
    //sxy.add(x[0], y[0]);
    pesos = new double[imc.imc.length];
    fecha = new String[imc.fecha.length];
    pesos = imc.imc;
    fecha = imc.fecha;
    ///////////////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 MCM", "Fecha", "IMC", 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.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());
    }/* w w w .  j  ava 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:dpnm.netmsuite.plc.manager.frontend.graph.TimeSeriesChartDemo1.java

/**
 * Creates a chart./*from  w  w w  .j  ava  2 s. co  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;

}