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

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

Introduction

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

Prototype

public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer) 

Source Link

Document

Creates a new plot with the specified dataset, axes and renderer.

Usage

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setAutoRangeIncludesZero(false);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    XYShapeRenderer xyshaperenderer = new XYShapeRenderer();
    LookupPaintScale lookuppaintscale = new LookupPaintScale(1.0D, 4D, new Color(0, 0, 255));
    lookuppaintscale.add(2D, new Color(100, 100, 255));
    lookuppaintscale.add(3D, new Color(200, 200, 255));
    xyshaperenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyshaperenderer);
    xyplot.setDomainPannable(true);/*  w  ww  . ja va2  s.  co  m*/
    xyplot.setRangePannable(true);
    JFreeChart jfreechart = new JFreeChart("XYShapeRendererDemo1", xyplot);
    jfreechart.removeLegend();
    NumberAxis numberaxis2 = new NumberAxis("Score");
    numberaxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, numberaxis2);
    paintscalelegend.setPosition(RectangleEdge.RIGHT);
    paintscalelegend.setMargin(4D, 4D, 40D, 4D);
    paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    jfreechart.addSubtitle(paintscalelegend);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis numberaxis1 = new NumberAxis("Y");
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.10000000000000001D);
    stackedxybarrenderer.setDrawBarOutline(false);
    XYPlot xyplot = new XYPlot(tablexydataset, numberaxis, numberaxis1, stackedxybarrenderer);
    JFreeChart jfreechart = new JFreeChart("Stacked XY Bar Chart Demo 1", xyplot);
    return jfreechart;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setLowerMargin(0.0D);/*  w  ww . j a  va  2  s.co m*/
    numberaxis.setUpperMargin(0.0D);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    numberaxis1.setInverted(true);
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black);
    lookuppaintscale.add(0.5D, Color.green);
    lookuppaintscale.add(1.5D, Color.orange);
    lookuppaintscale.add(2.5D, Color.red);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setForegroundAlpha(0.66F);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" });
    symbolaxis.setRange(0.5D, 3.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}

From source file:jamel.gui.charts.AbstractScatterChart.java

/**
 * Returns a new plot.//from ww w.  j a va2s  . c o  m
 * 
 * @param xySeries  the series.
 * @param xAxisLabel  the label of the horizontal axis.
 * @param yAxisLabel  the label of the vertical axis.
 * @return a new plot.
 */
static private Plot newPlot(XYSeries xySeries, String xAxisLabel, String yAxisLabel) {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    if (xySeries != null)
        dataset.addSeries(xySeries);
    final XYPlot plot = new XYPlot(dataset, new NumberAxis(xAxisLabel), new NumberAxis(yAxisLabel),
            new XYLineAndShapeRenderer(false, true));
    plot.setOrientation(PlotOrientation.VERTICAL);
    return plot;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLowerMargin(0.0D);/*from  w w w . j  av  a  2  s  . com*/
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setAxisLinePaint(Color.white);
    numberaxis.setTickMarkPaint(Color.white);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setAxisLinePaint(Color.white);
    numberaxis1.setTickMarkPaint(Color.white);
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    GrayPaintScale graypaintscale = new GrayPaintScale(-2D, 1.0D);
    xyblockrenderer.setPaintScale(graypaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinesVisible(false);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    xyplot.setOutlinePaint(Color.blue);
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo1", xyplot);
    jfreechart.removeLegend();
    NumberAxis numberaxis2 = new NumberAxis("Scale");
    numberaxis2.setAxisLinePaint(Color.white);
    numberaxis2.setTickMarkPaint(Color.white);
    numberaxis2.setTickLabelFont(new Font("Dialog", 0, 7));
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(new GrayPaintScale(), numberaxis2);
    paintscalelegend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    paintscalelegend.setFrame(new BlockBorder(Color.red));
    paintscalelegend.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
    paintscalelegend.setStripWidth(10D);
    paintscalelegend.setPosition(RectangleEdge.RIGHT);
    paintscalelegend.setBackgroundPaint(new Color(120, 120, 180));
    jfreechart.addSubtitle(paintscalelegend);
    jfreechart.setBackgroundPaint(new Color(180, 180, 250));
    return jfreechart;
}

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

private static XYPlot createSubplot1(XYDataset xydataset) {
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setBaseFillPaint(Color.white);
    xylineandshaperenderer.setBaseShape(new java.awt.geom.Ellipse2D.Double(-4D, -4D, 8D, 8D));
    xylineandshaperenderer.setAutoPopulateSeriesShape(false);
    NumberAxis numberaxis = new NumberAxis("Y");
    numberaxis.setLowerMargin(0.10000000000000001D);
    numberaxis.setUpperMargin(0.10000000000000001D);
    XYPlot xyplot = new XYPlot(xydataset, new DateAxis("Time"), numberaxis, xylineandshaperenderer);
    return xyplot;
}

From source file:logica.LGraficapeso.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;// w w  w .  j av a2s .  com
    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: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);// w ww  . j  av  a  2  s . c o 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.LGraficaAltura.java

public static void logicaBtnGraficar(JRadioButton jRLinea) {

    ChartPanel panel;/*from w  w  w . j a v a  2 s.  com*/
    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:org.jfree.chart.demo.XYBlockChartDemo2.java

private static JFreeChart createChart(XYZDataset xyzdataset) {
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setLowerMargin(0.0D);/*from  w w w  . j  a va  2  s  .  c  o m*/
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setInverted(true);
    NumberAxis numberaxis = new NumberAxis("Hour");
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    xyblockrenderer.setBlockWidth(86400000D);
    xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT);
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white);
    lookuppaintscale.add(0.5D, Color.red);
    lookuppaintscale.add(1.5D, Color.green);
    lookuppaintscale.add(2.5D, Color.blue);
    lookuppaintscale.add(3.5D, Color.yellow);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer);
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null,
            new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" });
    symbolaxis.setRange(0.5D, 4.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D));
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setAxisOffset(5D);
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}