<p>Hello,</p>
<p>I try to create a Gantt chart and group some Values but I can't find the fitting aggregate expression.</p>
<p>I want to group some category values together into one category line but everytime i try it with min/max or first/last I don't get the result i want. I know that it works as intended but I need to know if there is another way to get the result I want.</p>
<p>The problem with min/max is that BIRT doesn't care if there are values between the two dates or not.</p>
<p>I've attached a screenshot to show what i mean.</p>
<p>Maybe there is a way to manually create entries or something like that, any advice is appreciated.</p>
<p>I have a scripted data set, which contains 4 columns (startdate, enddate, category and group) and my chart code looks like that so far:</p>
<pre class="_prettyXprint">
public final static Chart createGantt( )
{
ChartWithAxes cwaGantt = ChartWithAxesImpl.create( );
cwaGantt.setType( "Gantt Chart" ); //$NON-NLS-1$
cwaGantt.setSubType( "Standard Gantt Chart" ); //$NON-NLS-1$
cwaGantt.setOrientation( Orientation.HORIZONTAL_LITERAL );
cwaGantt.getBlock().getBounds().setWidth( 400 );
cwaGantt.getBlock().getBounds().setHeight( 200 );
// Plot
cwaGantt.getBlock( ).setBackground( ColorDefinitionImpl.WHITE() );
cwaGantt.getBlock( ).getOutline( ).setVisible( true );
Plot p = cwaGantt.getPlot( );
p.getClientArea( ).setBackground( ColorDefinitionImpl.create( 255,255,225 ) );
// Title
cwaGantt.getTitle( ).getLabel( ).getCaption( ).setValue( "Gantt Chart" ); //$NON-NLS-1$
// Legend
Legend lg = cwaGantt.getLegend( );
lg.setItemType( LegendItemType.SERIES_LITERAL );
// X-Axis
Axis xAxisPrimary = cwaGantt.getPrimaryBaseAxes( )[0];
xAxisPrimary.setCategoryAxis( true );
xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );
xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );
// Y-Axis
Axis yAxisPrimary = cwaGantt.getPrimaryOrthogonalAxis( xAxisPrimary );
yAxisPrimary.setType( AxisType.DATE_TIME_LITERAL );
yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );
yAxisPrimary.getScale( ).setMin( DateTimeDataElementImpl.create( new CDateTime(2008,1,1) ) );
yAxisPrimary.getScale( ).setMax( DateTimeDataElementImpl.create( new CDateTime(2009,1,1) ) );
DateFormatSpecifier dfs = AttributeFactory.eINSTANCE.createDateFormatSpecifier( );
dfs.setDetail( DateFormatDetail.DATE_LITERAL );
dfs.setType( DateFormatType.MEDIUM_LITERAL );
yAxisPrimary.setFormatSpecifier( dfs );
SampleData sd = DataFactory.eINSTANCE.createSampleData( );
BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData( );
sdBase.setDataSetRepresentation( "" );//$NON-NLS-1$
sd.getBaseSampleData( ).add( sdBase );
OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE.createOrthogonalSampleData( );
sdOrthogonal1.setDataSetRepresentation( "" );//$NON-NLS-1$
sdOrthogonal1.setSeriesDefinitionIndex( 0 );
sd.getOrthogonalSampleData( ).add( sdOrthogonal1 );
cwaGantt.setSampleData( sd );
// X-Series
Series seCategory = SeriesImpl.create( );
seCategory.getDataDefinition().add( QueryImpl.create("row[\"Kategorie\"]"));
SeriesDefinition sdX = SeriesDefinitionImpl.create( );
sdX.getSeriesPalette( ).shift( 0 );
sdX.getGrouping().setEnabled( true );
sdX.getGrouping().setGroupType( DataType.TEXT_LITERAL );
sdX.getGrouping().setGroupingInterval( 1 );
xAxisPrimary.getSeriesDefinitions( ).add( sdX );
sdX.getSeries( ).add( seCategory );
// Y-Series
GanttSeries serie1 = (GanttSeries) GanttSeriesImpl.create( );
serie1.getLabel( ).setVisible( false );
Query query1 = QueryImpl.create( "row[\"Startdatum\"]" );
Query query2 = QueryImpl.create( "row[\"Enddatum\"]" );
Query query3 = QueryImpl.create( "row[\"Kategorie\"]" );
Query query4 = QueryImpl.create( "row[\"Gruppe\"]" );
SeriesGrouping q1 =SeriesGroupingImpl.create( );
q1.setAggregateExpression("Min");
q1.setEnabled(true);
q1.setGroupType( DataType.TEXT_LITERAL );
query1.setGrouping(q1);
SeriesGrouping q2 =SeriesGroupingImpl.create( );
q2.setAggregateExpression("Max");
q2.setEnabled(true);
q2.setGroupType( DataType.TEXT_LITERAL );
query2.setGrouping(q2);
ArrayList<Query> list = new ArrayList<Query>();
list.add(query1);
list.add(query2);
list.add(query3);
serie1.getDataDefinition().addAll( list );
SeriesDefinition sdY = SeriesDefinitionImpl.create();
sdY.getSeries().add( serie1 );
sdY.setQuery( query4 );
yAxisPrimary.getSeriesDefinitions().add(sdY);
return cwaGantt;
}
</pre>
<p>I have already tried it within the report designer some weeks before and had the same problem (see here <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/35237-need-help-with-my-gantt-chart/'>http://developer.actuate.com/community/forum/index.php?/topic/35237-need-help-with-my-gantt-chart/</a>) and I thought I could solve my problem within java but I have no clue how I can do that. </p>
<p> </p>
<p>I saw a code in the chart examples where the Gantt entries get created manually but I can't get the code working for my own chart:</p>
<pre class="_prettyXprint">
GanttDataSet phase1 = GanttDataSetImpl.create( new GanttEntry[]{
new GanttEntry( new CDateTime( 2008, 1, 9 ),
new CDateTime( 2008, 6, 9 ),
"Task A" ), //$NON-NLS-1$
new GanttEntry( new CDateTime( 2008, 3, 9 ),
new CDateTime( 2008, 8, 9 ),
"Task B" ), //$NON-NLS-1$
new GanttEntry( new CDateTime( 2008, 5, 24 ),
new CDateTime( 2008, 9, 9 ),
"Task C" ) //$NON-NLS-1$
} );
GanttDataSet phase2 = GanttDataSetImpl.create( new GanttEntry[]{
new GanttEntry( new CDateTime( 2008, 6, 12 ),
new CDateTime( 2008, 9, 23 ),
"Task A" ), //$NON-NLS-1$
new GanttEntry( new CDateTime( 2008, 8, 9 ),
new CDateTime( 2008, 8, 9 ),
"Task B" ), //$NON-NLS-1$
new GanttEntry( new CDateTime( 2008, 9, 9 ),
new CDateTime( 2008, 12, 9 ),
"Task C" ) //$NON-NLS-1$
} );
</pre>
<p>Help me please

</p>