final SeriesGrouping sg = sd.getGrouping( ); if ( sg == null || !sg.isEnabled( ) )
if ( !needBaseGrouping )
	public void applyBaseSeriesSortingAndGrouping( SeriesDefinition sd,			String[] saExpressionKeys ) throws ChartException	{		// PREVENT REDUNDANT GROUPING		if ( bBaseGroupingApplied )		{			return;		}		bBaseGroupingApplied = true;		// Apply base series sorting.		final Series seBaseDesignTime = sd.getDesignTimeSeries( );		final Query q = (Query) seBaseDesignTime.getDataDefinition( ).get( 0 );		final int iSortColumnIndex = ( (Integer) htLookup.get( q.getDefinition( ) ) ).intValue( );		SortOption so = null;		if ( !sd.isSetSorting( ) )		{			logger.log( ILogger.WARNING,					Messages.getString( "warn.unspecified.sorting", //$NON-NLS-1$							new Object[]{								sd							},							ULocale.getDefault( ) ) );			so = SortOption.ASCENDING_LITERAL;		}		else		{			so = sd.getSorting( );		}		new GroupingSorter( ).sort( workingResultSet,				iSortColumnIndex,				so,				iaGroupBreaks );		// VALIDATE SERIES GROUPING		final SeriesGrouping sg = sd.getGrouping( );		if ( sg == null || !sg.isEnabled( ) )		{			return;		}		// LOOKUP AGGREGATE FUNCTION		final String sFunctionName = sg.getAggregateExpression( );		final int iOrthogonalSeriesCount = saExpressionKeys.length;		IAggregateFunction[] iafa = new IAggregateFunction[iOrthogonalSeriesCount];		try		{			for ( int i = 0; i < iOrthogonalSeriesCount; i++ )			{				iafa[i] = PluginSettings.instance( )						.getAggregateFunction( sFunctionName );				iafa[i].initialize( );			}		}		catch ( ChartException pex )		{			throw new ChartException( ChartEnginePlugin.ID,					ChartException.DATA_BINDING,					pex );		}		final DataType dtGrouping = sg.getGroupType( );		if ( dtGrouping == DataType.NUMERIC_LITERAL )		{			groupNumerically( workingResultSet,					iSortColumnIndex,					saExpressionKeys,					iaGroupBreaks,					null,					sg.getGroupingInterval( ),					iafa );		}		else if ( dtGrouping == DataType.DATE_TIME_LITERAL )		{			groupDateTime( workingResultSet,					iSortColumnIndex,					saExpressionKeys,					iaGroupBreaks,					null,					sg.getGroupingInterval( ),					sg.getGroupingUnit( ),					iafa );		}		else if ( dtGrouping == DataType.TEXT_LITERAL )		{			groupTextually( workingResultSet,					iSortColumnIndex,					saExpressionKeys,					iaGroupBreaks,					null,					sg.getGroupingInterval( ),					iafa );		}		// re-initialize meta since Aggretation could change data type(text->count)		initializeMeta( );	}