Example usage for org.jfree.chart ChartFactory createXYAreaChart

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

Introduction

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

Prototype

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

Source Link

Document

Creates an area chart using an XYDataset .

Usage

From source file:statistic.graph.gui.Charts.java

public static JFreeChart createXYAreaChart(DiagramData data, XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYAreaChart(data.getTitle(), data.getXAxisLabel(),
            data.getYAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false);
    initXAxis(chart.getXYPlot(), dataset);
    return chart;
}

From source file:com.thecoderscorner.groovychart.chart.XYAreaChart.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createXYAreaChart(this.getTitle(), this.getXAxisLabel(),
            this.getYAxisLabel(), (XYDataset) this.getDataset(), this.getOrientation(), this.isLegend(),
            this.isTooltips(), this.isUrls());
    return setExtraProperties(chart);

}

From source file:Logica.Graficas.java

public void tipoGrafica(int tipo) {
    switch (tipo) {
    case LINEAL:/*from   w w  w  .  j  a v  a2s.c  om*/
        grafica = ChartFactory.createXYLineChart(null, tx, ty, datos, PlotOrientation.VERTICAL, true, true,
                true);
        break;
    case AREA:
        grafica = ChartFactory.createXYAreaChart(null, tx, ty, datos, PlotOrientation.VERTICAL, true, true,
                true);
        break;
    }
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart("XYAreaRenderer2Demo1", "Domain (X)", "Range (Y)",
            xydataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setRenderer(new XYAreaRenderer2());
    xyplot.setForegroundAlpha(0.65F);//  ww  w .  j  av  a 2 s .c  o  m
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)",
            xydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setForegroundAlpha(0.65F);/*from www  .j  a v  a2 s.c o  m*/
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D);
    xypointerannotation.setTipRadius(0.0D);
    xypointerannotation.setBaseRadius(35D);
    xypointerannotation.setFont(new Font("SansSerif", 0, 9));
    xypointerannotation.setPaint(Color.blue);
    xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT);
    xyplot.addAnnotation(xypointerannotation);
    return jfreechart;
}

From source file:dr.PlotPanel.java

public PlotPanel(PCADataset dataset) {
    super(null);/*from w ww. j  a v a2  s.  c  o m*/

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new PlotRenderer(plot, dataset);
    itemLabelGenerator = new PlotItemLabelGenerator();
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new PlotToolTipGenerator());

    plot.setRenderer(spotRenderer);

}

From source file:gchisto.gui.panels.gcdistribution.ChartPanelAll.java

/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 *///from ww w. j  a  va  2  s .  co  m
private void addChart(XYDatasetWithGroups dataset) {
    assert dataset != null;

    JFreeChart chart = ChartFactory.createXYAreaChart(getTitle(), "Buckets (sec)", "Count", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    // null so that we can get it compiled; we'll get back to this...
    GroupActivatingPanel table = new GroupActivatingPanel(dataset, null);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, table,
            new org.jfree.chart.ChartPanel(chart));
    splitPane.setDividerLocation(200);
    mainPanel().add(BorderLayout.CENTER, splitPane);
}

From source file:org.operamasks.faces.render.graph.AreaChartRenderer.java

protected JFreeChart createChart(UIChart comp) {
    Dataset dataset = createDataset(comp);
    JFreeChart chart = null;//from  w  w  w . j av  a  2  s.  com

    if (dataset instanceof CategoryDataset) {
        if (comp.isStacked()) {
            chart = ChartFactory.createStackedAreaChart(null, null, null, (CategoryDataset) dataset,
                    getChartOrientation(comp), false, false, false);
        } else {
            chart = ChartFactory.createAreaChart(null, null, null, (CategoryDataset) dataset,
                    getChartOrientation(comp), false, false, false);
        }
    } else if (dataset instanceof XYDataset) {
        chart = ChartFactory.createXYAreaChart(null, null, null, (XYDataset) dataset, getChartOrientation(comp),
                false, false, false);

        if (dataset instanceof TimeSeriesCollection) {
            DateAxis xAxis = new DateAxis(null);
            xAxis.setLowerMargin(0.02);
            xAxis.setUpperMargin(0.02);
            ((XYPlot) chart.getPlot()).setDomainAxis(xAxis);
        }
    }

    return chart;
}

From source file:openomr.dataanalysis.XYChart.java

public XYChart(int data[], int size, String name) {
    XYSeries series = new XYSeries(name);
    for (int i = 0; i < size; i += 1)
        series.add(i, data[i]);//from  www.  ja v a2 s  .co  m
    XYDataset xyDataset = new XYSeriesCollection(series);

    chart = ChartFactory.createXYAreaChart(name, "width", "# Pixels", xyDataset, PlotOrientation.VERTICAL, true,
            false, false);

}

From source file:net.sf.mzmine.modules.peaklistmethods.dataanalysis.projectionplots.ProjectionPlotPanel.java

public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
        ParameterSet parameters) {//from  w w  w . j  ava  2  s. c  om
    super(null);

    boolean createLegend = false;
    if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20))
        createLegend = true;

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, createLegend, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new ProjectionPlotRenderer(plot, dataset);
    itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
    plot.setRenderer(spotRenderer);

    // Setup legend
    if (createLegend) {
        LegendItemCollection legendItemsCollection = new LegendItemCollection();
        for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
            Object paramValue = dataset.getGroupParameterValue(groupNumber);
            if (paramValue == null) {
                // No parameter value available: search for raw data files
                // within this group, and use their names as group's name
                String fileNames = new String();
                for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
                    String rawDataFile = dataset.getRawDataFile(itemNumber);
                    if (dataset.getGroupNumber(itemNumber) == groupNumber)
                        fileNames = fileNames.concat(rawDataFile);
                }
                if (fileNames.length() == 0)
                    fileNames = "Empty group";

                paramValue = fileNames;
            }
            Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
            Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
                    (int) Math.round(255 * dataPointAlpha));
            legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
                    spotRenderer.getDataPointsShape(), groupColor));
        }
        plot.setFixedLegendItems(legendItemsCollection);
    }

}