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:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

protected JFreeChart createXyAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true,
            false);/* ww w . j a v  a2  s. c om*/

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

protected JFreeChart createXyAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true,
            false);//from w w w .  j a v a 2 s. c  om

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

protected JFreeChart createXyAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true,
            false);/*  w w  w .  ja  v  a  2s.c o m*/

    configureChart(jfreeChart);
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));
    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java

private JFreeChart createXYAreaChart(String title, String xLabel, String yLabel, XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart(title, xLabel, yLabel, dataset, orientation, true, // legend
            true, // tool tips
            false // URLs
    );/*from   ww  w . j  a  v  a2s .  c  om*/

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    if (timeType.length() != 0) {
        setDateAxis(plot);
    } else {
        ValueAxis domainAxis = plot.getDomainAxis();
        domainAxis.setTickMarkPaint(Color.black);
        domainAxis.setLowerMargin(0.0);
        domainAxis.setUpperMargin(0.0);

        ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setTickMarkPaint(Color.black);
    }

    //XYItemRenderer renderer = plot.getRenderer();
    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    return chart;
}

From source file:course_generator.frmMain.java

private JFreeChart CreateChartProfil(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYAreaChart("", "Distance", // x
            // axis
            // label
            "Elevation", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );//from w  w  w  .  j a  v a  2s. c o m

    chart.setBackgroundPaint(Color.white); // Panel background color
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);

    // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); // Green (safe
    // color)
    renderer.setOutline(true);
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); // Width of
    // the
    // outline
    plot.setRenderer(renderer);

    // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}