Jump to content
Changes to the Jaspersoft community edition download ×

Gantt chart

2005 IR Help

Recommended Posts

By: brunello - brunello

Gantt chart

2005-04-22 08:33

Hi, do you know how to make a Gantt chart?


In the chart properties, i can't see this type of report


Sorry for my bad english







By: Franck Andriano - altern

RE: Gantt chart

2005-04-26 08:45



Just do it! :)


Giulio can you implement it ?



File DefaultChartFactory.java :


else if ( chartName.equals(GANTT) )


Vector valuesY = getSeries("serie0", props,scriptlet); // task name

Vector valuesPercent = getSeries("serie1", props,scriptlet); // task pourcentage


Vector theDateStartSeries = getSeries("serie2", props,scriptlet); // date start

Vector theDateEndSeries = getSeries("serie3", props,scriptlet); // date end


GanttCategoryDataset dataset = null;


if (scriptlet == null)


dataset = getGanttSampleCategoryDataset();




TaskSeriesCollection collection = new TaskSeriesCollection();

Task t = null;


TaskSeries s1 = new TaskSeries(props.getProperty("title"));//we have just a single series of tasks


for (int i=0; i<valuesY.size(); ++i)


t = new Task((String) valuesY.get(i), (Date) theDateStartSeries.get(i), (Date) theDateEndSeries.get(i) );

t.setPercentComplete(Double.parseDouble((String) valuesPercent.get(i)));

s1.add(t); //add the new task to the task series



collection.add(s1); //add the new Series to dataset collection

dataset = collection;



JFreeChart chart = null;


chart = org.jfree.chart.ChartFactory.createGanttChart("",




showLegend, // include legend

showTooltips, // tooltips?

false // URLs?



setChartProperties(props, chart);


CategoryPlot plot = (CategoryPlot) chart.getPlot();

CategoryItemRenderer renderer = plot.getRenderer();

renderer.setSeriesPaint(0, getParameterAsColor("barColor",props, java.awt.Color.blue));


return chart.createBufferedImage(width*quality,height*quality);




Task t = null;

TaskSeriesCollection collection = new TaskSeriesCollection();


TaskSeries s1 = new TaskSeries("Project1");//we have just a single series of tasks

t = new Task("Task1", date(2, 10, 2005), date(2,11,2005) );

t.setPercentComplete(Double.parseDouble("0.5")); // 50%

s1.add(t );//add the new task to the task series


t = new Task("Task2", date(2, 11, 2005), date(2,12,2005) );

t.setPercentComplete(Double.parseDouble("0.3")); // 70%

s1.add(t);//add the new task to the task series


collection.add(s1); //add the new Series to collection


return collection;



private static Date date(int day, int month, int year)


// this may look a bit nuts but parameters are passed as strings so I don't want any confusion between dd/mm/yyyy and mm/dd/yyyy

Calendar calendar = Calendar.getInstance();

calendar.set(year, --month, day);//month is 0 based 0 is January, 11 is December

Date result = calendar.getTime();

return result;



File *.jrxml :


<imageExpression class="java.awt.Image"><![CDATA[(java.awt.Image)it.businesslogic.ireport.chart.DefaultChartFactory.drawChart(new String[]{"antialias=true","tooltips=false","legend=false","chartName=Gantt","foregroundAlpha=0.33","subtitle=","plotBackground=[255,255,255]","quality=2","height=207","titlePosition=1","barColor=[0,0,255]","chartBackground=[255,255,255]","width=491","serie3=SERIE_DATE_END","serie2=SERIE_DATE_START","serie1=SERIE_POURCENT","serie0=SERIE_TASK","title=All Tasks"}, (it.businesslogic.ireport.IReportScriptlet)$P{REPORT_SCRIPTLET})]]></imageExpression> </image>









By: brunello - brunello

RE: Gantt chart

2005-04-27 08:31

Thanks for your help



Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...