Example usage for org.jfree.chart ChartFactory createXYLineChart

List of usage examples for org.jfree.chart ChartFactory createXYLineChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createXYLineChart.

Prototype

public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a line chart (based on an XYDataset ) with default settings.

Usage

From source file:com.windows.Chart.java

public static JFreeChart createChart(XYDataset dataset) {
    //   //www. jav a 2 s  . c  om
    JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLine Chart Demo", //    
            "??", // categoryAxisLabel categoryX      
            "?", // valueAxisLabelvalueY      
            dataset, // dataset      
            PlotOrientation.VERTICAL, true, // legend      
            false, // tooltips      
            false); // URLs   
    // CategoryPlot?????      
    XYPlot plot = (XYPlot) jfreechart.getPlot();
    //  ?      
    plot.setBackgroundAlpha(0.5f);
    return jfreechart;
}

From source file:it.unifi.rcl.chess.traceanalysis.gui.Plotter.java

public static JPanel assemblePlot(XYSeries series[]) {
    // Add the series to your data set
    XYSeriesCollection dataset = new XYSeriesCollection();
    for (int i = 0; i < series.length; i++) {
        dataset.addSeries(series[i]);//from  ww w .ja  v a  2 s.  c  om
    }

    // Generate the graph
    JFreeChart chart = ChartFactory.createXYLineChart("XY Chart",
            // Title
            "x-axis",
            // x-axis Labels
            "y-axis",
            // y-axis Label
            dataset,
            // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false,
            // Show Legend
            true,
            // Use tooltips
            false
    // Configure chart to generate URLs?
    );

    return new ChartPanel(chart);
}

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

public static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Normal Distribution", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, true, true, false);
    return jfreechart;
}

From source file:com.moczul.jbacktester.Main.java

private static void showChart(XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYLineChart("PKO - PEO", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//from   w  ww .  j  a v a2  s. c  o  m

    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));

    XYPlot plot = chart.getXYPlot();
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(2, false);
    renderer.setSeriesShapesVisible(3, false);
    renderer.setSeriesShapesVisible(4, false);
    plot.setRenderer(renderer);

    JFrame frame = new JFrame();
    frame.setContentPane(chartPanel);

    frame.pack();
    frame.setVisible(true);
}

From source file:simulador.controle.GraficoCategorias.java

public static JFreeChart gerarGrafico(Map<String, Map<Float, Float>> dados) {

    if (DEBUG) {/* w w  w  . j  a  v  a 2  s  .  c o  m*/
        System.out.println("GraficoRadiais.gerarGrafico");
    }

    String tituloGrafico = "Potncia do Sinal Vs Distncia";
    String tituloEixoX = "Distncia (m)";
    String tituloEixoY = "Potncia (dBm)";

    //XYSeriesCollection dadosGrafico = criarDataset(mapaCelulas, painelDesign, ambiente);
    XYSeriesCollection dadosGrafico = criarDataset(dados);

    JFreeChart grafico = ChartFactory.createXYLineChart(tituloGrafico, tituloEixoX, tituloEixoY, dadosGrafico,
            PlotOrientation.VERTICAL, true, true, false);

    //renderizarGrafico(grafico);

    return grafico;

}

From source file:eu.cassandra.csn.gui.Charts.java

/**
 * /*from  w w  w  .j a va  2s .  c o  m*/
 * @param title
 * @param x
 * @param y
 * @param data
 * @return
 */
public static ChartPanel createGraph(String title, String x, String y, Double[] data) {
    XYSeries series1 = new XYSeries("First");
    for (int i = 0; i < data.length; i++) {
        series1.add(i, data[i]);
    }
    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);

    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, urls);
    //XYPlot plot = (XYPlot) chart.getPlot();  

    ChartPanel cp = new ChartPanel(chart);
    return cp;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYLineChart("Marker Demo 2", "X", "Temperature", xydataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainGridlinePaint(Color.lightGray);
    xyplot.setDomainGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeGridlinePaint(Color.lightGray);
    xyplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    xyplot.setRangeTickBandPaint(new Color(240, 240, 240));
    PeriodAxis periodaxis = new PeriodAxis(null, new Hour(0, 30, 6, 2005), new Hour(23, 30, 6, 2005));
    PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[2];
    aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Hour.class,
            new SimpleDateFormat("HH"));
    aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class,
            new SimpleDateFormat("dd-MMM"));
    periodaxis.setLabelInfo(aperiodaxislabelinfo);
    xyplot.setDomainAxis(periodaxis);//w  ww  .  j a v a  2s .c o m
    ValueAxis valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 100D);
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    xyitemrenderer.setSeriesPaint(0, Color.green);
    xyitemrenderer.setSeriesStroke(0, new BasicStroke(2.0F));
    ValueMarker valuemarker = new ValueMarker(80D);
    valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    valuemarker.setPaint(Color.red);
    valuemarker.setStroke(new BasicStroke(2.0F));
    valuemarker.setLabel("Temperature Threshold");
    valuemarker.setLabelFont(new Font("SansSerif", 0, 11));
    valuemarker.setLabelPaint(Color.red);
    valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
    xyplot.addRangeMarker(valuemarker);
    Hour hour = new Hour(18, 30, 6, 2005);
    Hour hour1 = new Hour(20, 30, 6, 2005);
    double d = hour.getFirstMillisecond();
    double d1 = hour1.getFirstMillisecond();
    IntervalMarker intervalmarker = new IntervalMarker(d, d1);
    intervalmarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    intervalmarker.setPaint(new Color(150, 150, 255));
    intervalmarker.setLabel("Automatic Cooling");
    intervalmarker.setLabelFont(new Font("SansSerif", 0, 11));
    intervalmarker.setLabelPaint(Color.blue);
    intervalmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    xyplot.addDomainMarker(intervalmarker, Layer.BACKGROUND);
    ValueMarker valuemarker1 = new ValueMarker(d, Color.blue, new BasicStroke(2.0F));
    ValueMarker valuemarker2 = new ValueMarker(d1, Color.blue, new BasicStroke(2.0F));
    xyplot.addDomainMarker(valuemarker1, Layer.BACKGROUND);
    xyplot.addDomainMarker(valuemarker2, Layer.BACKGROUND);
    return jfreechart;
}

From source file:FECTester.Chart.java

public Chart(String name, String xLabel, String yLabel) {
    super(name);// ww w . j  a  va  2 s.com
    JFreeChart lineChart = ChartFactory.createXYLineChart(name, xLabel, yLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(lineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(600, 450));
    setContentPane(chartPanel);
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setSize(600, 450);
    this.setResizable(false);
    this.setVisible(false);
}

From source file:br.unicamp.cst.util.ChartViewerUtil.java

public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title,
        String categoryAxisLabel, String valueAxisLabel, long timeRefresh) {

    final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100);
    chart.setBackgroundPaint(Color.lightGray);

    ChartPanel localChartPanel = new ChartPanel(chart);
    localChartPanel.setVisible(true);/*from ww  w. j  ava 2  s.  c  om*/
    localChartPanel.setDomainZoomable(true);

    return localChartPanel;
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {/*from  w w  w.  j  a va  2  s . co m*/
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}