rsw.applyBaseSeriesSortingAndGrouping( sdGrouping, saOrthogonalDataDefinitions );
if ( rsw.getRowCount( ) > 0 ) {  rsw.applyBaseSeriesSortingAndGrouping( sdGrouping, saOrthogonalDataDefinitions ); }
	protected ResultSetWrapper mapToChartResultSet(			IDataRowExpressionEvaluator idre, Chart cm ) throws ChartException	{		// Collect all used data expressions		LinkedHashMap lhmLookup = new LinkedHashMap( );		Collection co = getRowExpressions( cm, iae );		Iterator it = co.iterator( );		String sxp;		int i = 0;		while ( it.hasNext( ) )		{			sxp = (String) it.next( );			lhmLookup.put( sxp, new Integer( i++ ) );		}		// WALK THROUGH RESULTS		final int iColumnCount = i;		final List liResultSet = new ArrayList( );		Object[] oaTuple;		int iColumnIndex;		boolean hasFirst = idre.first( );		if ( hasFirst )		{			do			{				oaTuple = new Object[iColumnCount];				it = co.iterator( );				iColumnIndex = 0;				while ( it.hasNext( ) )				{					oaTuple[iColumnIndex++] = idre.evaluate( (String) it.next( ) );				}				liResultSet.add( oaTuple );			} while ( idre.next( ) );		}		// !Don't close evaluator here, let creator close it.		// idre.close( );		// Prepare orthogonal grouping keys		final GroupKey[] groupKeys = findGroupKeys( cm );		// update key index.		for ( i = 0; i < groupKeys.length; i++ )		{			groupKeys[i].setKeyIndex( ( (Integer) lhmLookup.get( groupKeys[i].getKey( ) ) ).intValue( ) );		}		// create resultset wrapper		final ResultSetWrapper rsw = new ResultSetWrapper( lhmLookup.keySet( ),				liResultSet,				groupKeys );		SeriesDefinition sdGrouping = null;		String[] saOrthogonalDataDefinitions = null;		// TODO ??do we need processing trigger expr too?		// search all orthogonal series data definitions for base grouping		if ( cm instanceof ChartWithAxes )		{			ArrayList alODD = new ArrayList( 8 );			ChartWithAxes cwa = (ChartWithAxes) cm;			Axis[] axaBase = cwa.getBaseAxes( );			Axis[] axaOrthogonal = null;			Series SE;			String sExpression;			EList elSD, elDD;			// EACH BASE AXIS			for ( int j = 0; j < axaBase.length; j++ )			{				sdGrouping = (SeriesDefinition) axaBase[j].getSeriesDefinitions( )						.get( 0 );				axaOrthogonal = cwa.getOrthogonalAxes( axaBase[j], true );				// EACH ORTHOGONAL AXIS				for ( i = 0; i < axaOrthogonal.length; i++ )				{					elSD = axaOrthogonal[i].getSeriesDefinitions( );					// EACH ORTHOGONAL SERIES					for ( int k = 0; k < elSD.size( ); k++ )					{						SE = ( (SeriesDefinition) elSD.get( k ) ).getDesignTimeSeries( );						if ( SE != null )						{							elDD = SE.getDataDefinition( );							// FOR EACH QUERY							for ( int n = 0; n < elDD.size( ); n++ )							{								sExpression = ( (Query) elDD.get( n ) ).getDefinition( );								if ( sExpression != null										&& sExpression.trim( ).length( ) > 0										&& !alODD.contains( sExpression ) )								{									// ADD NEW VALID EXPRESSION									alODD.add( sExpression );								}							}						}					}				}			}			saOrthogonalDataDefinitions = (String[]) alODD.toArray( new String[alODD.size( )] );		}		else if ( cm instanceof ChartWithoutAxes )		{			ArrayList alODD = new ArrayList( 8 );			ChartWithoutAxes cwoa = (ChartWithoutAxes) cm;			Series SE;			String sExpression;			EList elSD, elDD;			sdGrouping = (SeriesDefinition) cwoa.getSeriesDefinitions( )					.get( 0 );			elSD = sdGrouping.getSeriesDefinitions( );			// EACH ORTHOGONAL SERIES			for ( int k = 0; k < elSD.size( ); k++ )			{				SE = ( (SeriesDefinition) elSD.get( k ) ).getDesignTimeSeries( );				if ( SE != null )				{					elDD = SE.getDataDefinition( );					// FOR EACH QUERY					for ( int n = 0; n < elDD.size( ); n++ )					{						sExpression = ( (Query) elDD.get( n ) ).getDefinition( );						if ( sExpression != null								&& sExpression.trim( ).length( ) > 0								&& !alODD.contains( sExpression ) )						{							// ADD NEW VALID EXPRESSION							alODD.add( sExpression );						}					}				}			}			saOrthogonalDataDefinitions = (String[]) alODD.toArray( new String[alODD.size( )] );		}		// apply base series grouping		rsw.applyBaseSeriesSortingAndGrouping( sdGrouping, saOrthogonalDataDefinitions );		return rsw;	}