Example usage for org.jfree.chart JFreeChart JFreeChart

List of usage examples for org.jfree.chart JFreeChart JFreeChart

Introduction

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

Prototype

public JFreeChart(Plot plot) 

Source Link

Document

Creates a new chart based on the supplied plot.

Usage

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

private static JFreeChart createChart(ValueDataset valuedataset) {
    CompassPlot compassplot = new CompassPlot(valuedataset);
    compassplot.setSeriesNeedle(7);// w w  w.  ja va  2  s. c o m
    compassplot.setSeriesPaint(0, Color.black);
    compassplot.setSeriesOutlinePaint(0, Color.black);
    compassplot.setRosePaint(Color.red);
    compassplot.setRoseHighlightPaint(Color.gray);
    compassplot.setRoseCenterPaint(Color.white);
    compassplot.setDrawBorder(false);
    JFreeChart jfreechart = new JFreeChart(compassplot);
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    DateAxis dateaxis = new DateAxis("Date");
    NumberAxis numberaxis = new NumberAxis("Y");
    XYBarRenderer xybarrenderer = new XYBarRenderer();
    xybarrenderer.setUseYInterval(true);
    XYPlot xyplot = new XYPlot(intervalxydataset, dateaxis, numberaxis, xybarrenderer);
    JFreeChart jfreechart = new JFreeChart(xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.white);
    return jfreechart;
}

From source file:daylightchart.options.chart.BaseChartOptions.java

private static JFreeChart createDummyChart() {
    final JFreeChart chart = new JFreeChart(new XYPlot());
    chart.setTitle("");
    final XYPlot plot = chart.getXYPlot();
    plot.setDomainAxis(new DateAxis());
    plot.setRangeAxis(new DateAxis());
    return chart;
}

From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java

public static ChartPanel CreateChartPanel(XYDataset dataset, Color[] colors) {
    XYPlot xy = createXYPlot(dataset, colors);
    JFreeChart chart = new JFreeChart(xy);
    ChartPanel chartPanel = new SpectrumChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setMouseZoomable(true);// ww w  . java  2 s  . c om
    // Remove the autogenerated subtitle
    if (chart.getSubtitleCount() == 1)
        chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1));
    return chartPanel;
}

From source file:JchartTest.GetChartAction.java

@Override
public String execute() throws Exception {
    ValueAxis xAxis = new NumberAxis("Input Increase");
    ValueAxis yAxis = new NumberAxis("Production");
    XYSeries xySeries = new XYSeries(new Integer(1));
    xySeries.add(0, 200);/*from  www.j a v a  2  s .co m*/
    xySeries.add(1, 300);
    xySeries.add(2, 500);
    xySeries.add(3, 700);
    xySeries.add(4, 700);
    xySeries.add(5, 900);
    XYSeriesCollection xyDataset = new XYSeriesCollection(xySeries);
    // create XYPlot
    XYPlot xyPlot = new XYPlot(xyDataset, xAxis, yAxis,
            new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES));
    chart = new JFreeChart(xyPlot);
    return SUCCESS;
}

From source file:logica.LGraficapeso.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;/*from ww w.j  a v a  2 s  .co m*/
    JFreeChart chart = null;

    if (jRLinea.isSelected()) {
        // ejecuto linea

        XYSplineRenderer graficoLinea = new XYSplineRenderer();

        XYSeriesCollection dataset = new XYSeriesCollection();

        ValueAxis x = new NumberAxis();
        ValueAxis y = new NumberAxis();

        XYSeries serie = new XYSeries("Datos");

        XYPlot plot;

        graficoLinea.setSeriesPaint(0, Color.YELLOW);

        VGraficaPeso.getPanelLinea().removeAll();

        for (int i = 0; i < VGraficaPeso.getjTable1().getRowCount(); i++) {

            float valor1 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 0)));
            float valor2 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 1)));

            System.out.println("valores  " + valor1 + "   " + valor2);

            serie.add(valor1, valor2);

        }

        dataset.addSeries(serie);

        x.setLabel("MES");
        y.setLabel("peso");

        plot = new XYPlot(dataset, x, y, graficoLinea);

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(10, 15);

        chart = new JFreeChart(plot);
        chart.setTitle("grafico");

        panel = new ChartPanel(chart);
        panel.setBounds(5, 10, 410, 350);

        VGraficaPeso.getPanelLinea().add(panel);
        VGraficaPeso.getPanelLinea().repaint();

    }

}

From source file:logica.LGraficaAltura.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;//  w ww .  ja  va2 s.  c  o m
    JFreeChart chart = null;

    if (jRLinea.isSelected()) {
        // ejecuto linea

        XYSplineRenderer graficoLinea = new XYSplineRenderer();

        XYSeriesCollection dataset = new XYSeriesCollection();

        ValueAxis x = new NumberAxis();
        ValueAxis y = new NumberAxis();

        XYSeries serie = new XYSeries("Datos");

        XYPlot plot;

        graficoLinea.setSeriesPaint(0, Color.YELLOW);

        VGraficaAltura.getPanelLinea().removeAll();

        for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) {

            float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0)));
            float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1)));

            System.out.println("valores  " + valor1 + "   " + valor2);

            serie.add(valor1, valor2);

        }

        dataset.addSeries(serie);

        x.setLabel("MES");
        y.setLabel("ALTURA");

        plot = new XYPlot(dataset, x, y, graficoLinea);

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(15, 30);

        chart = new JFreeChart(plot);
        chart.setTitle("grafico");

        panel = new ChartPanel(chart);
        panel.setBounds(5, 10, 410, 350);

        VGraficaAltura.getPanelLinea().add(panel);
        VGraficaAltura.getPanelLinea().repaint();

    }

}

From source file:rozpoznawanie_zad1_klasyf.ChartRenderer.java

public ChartRenderer(String tytul) {
    NumberAxis xAxis = new NumberAxis("Cecha 2");
    //     xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis("Cecha 1");
    //XYItemRenderer rend;
    // rend = new XYLineAndShapeRenderer(false, true);
    //XYItemRenderer rend = new XYLineAndShapeRenderer(true, false);
    XYDotRenderer rend = new XYDotRenderer();
    rend.setDotHeight(5);//from  ww  w  . j av a2s  .  c o  m
    rend.setDotWidth(5);
    XYPlot plot = new XYPlot(ds, xAxis, yAxis, rend);
    //      dataset.addSeries("sin", sin);

    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart fc = new JFreeChart(plot);
    cf = new ChartFrame(tytul, fc);
    cf.setSize(1280, 720);
}

From source file:grafix.graficos.ConstrutorGrafico.java

public JFreeChart criarJFreeChart() {
    //*debug*/ System.out.println("[PROFILE] criarJFreeChart() - " + janela.getAcao().getCodAcao());
    DateAxis domainAxis = getEixoHorizontal();
    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis);
    adicionarPlots(cplot);//ww  w. j a v a 2 s .  co m
    configurarEixoHorizontal(domainAxis);
    JFreeChart chart = new JFreeChart(cplot);
    configurarGrafico(chart);
    return chart;
}

From source file:wsattacker.plugin.intelligentdos.ui.helper.ChartHelper.java

public static JFreeChart createDumyChart() {
    final BoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    final CategoryAxis xAxis = new CategoryAxis("Type");
    final NumberAxis yAxis = new NumberAxis("Value");
    yAxis.setAutoRangeIncludesZero(false);
    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(true);//from   w  w w  .  j  a  v  a  2 s.c  om
    renderer.setMeanVisible(false);
    renderer.setMedianVisible(false);
    // renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
    final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    return new JFreeChart(plot);
}