Example usage for org.jfree.chart ChartFactory createGanttChart

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

Introduction

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

Prototype

public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel,
        IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a Gantt chart using the supplied attributes plus default values where required.

Usage

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

/**
 *
 *///  www .  j  av a2  s. c  om
protected JFreeChart createGanttChart() throws JRException {
    //FIXMECHART legend/tooltip/url should come from plot?

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createGanttChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            (String) evaluateExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (GanttCategoryDataset) getDataset(), isShowLegend(), true, //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
            false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true
            : barPlot.getShowTickMarks().booleanValue();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true
            : barPlot.getShowTickLabels().booleanValue();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();

    //FIXMETHEME these are useless if the theme settings apply after regardless of these; check all
    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(), (Comparable) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    ((DateAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(), (Comparable) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    BarRenderer categoryRenderer = (BarRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

/**
 *
 *///from  w  w w  . ja v  a 2s .  c  om
protected JFreeChart createGanttChart() throws JRException {
    //FIXMECHART legend/tooltip/url should come from plot?

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createGanttChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (GanttCategoryDataset) getDataset(), isShowLegend(), true, //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
            false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();

    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(), false, null,
            null);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    BarRenderer categoryRenderer = (BarRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    return jfreeChart;
}

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

/**
 *
 */// w  w  w .  ja  v a2  s  . c o  m
protected JFreeChart createGanttChart() throws JRException {
    //FIXMECHART legend/tooltip/url should come from plot?

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createGanttChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (GanttCategoryDataset) getDataset(), isShowLegend(), true, //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
            false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();

    //FIXMETHEME these are useless if the theme settings apply after regardless of these; check all
    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    ((DateAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(),
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    BarRenderer categoryRenderer = (BarRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    return jfreeChart;
}

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

/**
 *
 *///w  w  w . jav  a 2  s . c  om
protected JFreeChart createGanttChart() throws JRException {
    //FIXMECHART legend/tooltip/url should come from plot?

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createGanttChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (GanttCategoryDataset) getDataset(), isShowLegend(), true, //FIXMECHART tooltip: I guess BarPlot is not the best for gantt
            false);

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();

    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getCategoryAxisLineColor(), false, null, null);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((DateAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);
    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    GanttRenderer categoryRenderer = (GanttRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    categoryRenderer.setShadowVisible(false);

    return jfreeChart;
}