ex = ex.getCause( ); }  if ( ex instanceof ChartException && ( (ChartException) ex ).getType( ) == ChartException.ZERO_DATASET ) {
	public Object onRowSets( IRowSet[] irsa ) throws BirtException	{		// BIND RESULTSET TO CHART DATASETS		if ( irsa == null || irsa.length != 1 || irsa[0] == null )		{			// if the Data rows are null/empty, just log the error and returns			// null gracefully.			logger.log( new ChartException( ChartReportItemPlugin.ID,					ChartException.GENERATION,					"ChartReportItemPresentationImpl.error.NoData", //$NON-NLS-1$					Messages.getResourceBundle( rtc.getULocale( ) ) ) );			return null;		}		logger.log( ILogger.INFORMATION,				Messages.getString( "ChartReportItemPresentationImpl.log.onRowSetsStart" ) ); //$NON-NLS-1$		try		{			String javaHandlerClass = handle.getEventHandlerClass( );			if ( javaHandlerClass != null && javaHandlerClass.length( ) > 0 )			{				// use java handler if available.				cm.setScript( javaHandlerClass );			}			BIRTDataRowEvaluator rowAdapter = new BIRTDataRowEvaluator( irsa[0] );			Generator.instance( ).bindData( rowAdapter,					new BIRTActionEvaluator( ),					cm,					rtc );			logger.log( ILogger.INFORMATION,					Messages.getString( "ChartReportItemPresentationImpl.log.onRowSetsBuilding" ) ); //$NON-NLS-1$			// FETCH A HANDLE TO THE DEVICE RENDERER			idr = PluginSettings.instance( ).getDevice( "dv." //$NON-NLS-1$					+ sExtension.toUpperCase( Locale.US ) );			idr.setProperty( IDeviceRenderer.DPI_RESOLUTION, new Integer( dpi ) );			if ( "SVG".equalsIgnoreCase( sExtension ) ) //$NON-NLS-1$			{				idr.setProperty( "resize.svg", Boolean.TRUE ); //$NON-NLS-1$			}			// BUILD THE CHART			final Bounds originalBounds = cm.getBlock( ).getBounds( );			// we must copy the bounds to avoid that setting it on one object			// unsets it on its precedent container			final Bounds bo = (Bounds) EcoreUtil.copy( originalBounds );			logger.log( ILogger.INFORMATION,					Messages.getString( "ChartReportItemPresentationImpl.log.PresentationUsesBoundsBo", bo ) ); //$NON-NLS-1$			final Generator gr = Generator.instance( );			GeneratedChartState gcs = null;			rtc.setScriptClassLoader( new BIRTScriptClassLoader( ) );			rtc.setActionRenderer( new BIRTActionRenderer( this.handle,					this.ah,					rowAdapter,					this.context ) );			rtc.setMessageLookup( new BIRTMessageLookup( context ) );			Object renderContext = context.getAppContext( )					.get( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT );			// read RtL flag from engine			if ( renderContext instanceof HTMLRenderContext )			{				IRenderOption renderOption = ( (HTMLRenderContext) renderContext ).getRenderOption( );				if ( renderOption instanceof HTMLRenderOption )				{					if ( ( (HTMLRenderOption) renderOption ).getHtmlRtLFlag( ) )					{						rtc.setRightToLeft( true );					}				}			}			gcs = gr.build( idr.getDisplayServer( ),					cm,					bo,					new BIRTExternalContext( context ),					rtc,					new ChartReportStyleProcessor( handle, this.style ) );			// WRITE TO THE IMAGE FILE			logger.log( ILogger.INFORMATION,					Messages.getString( "ChartReportItemPresentationImpl.log.onRowSetsRendering" ) ); //$NON-NLS-1$			ByteArrayOutputStream baos = new ByteArrayOutputStream( );			BufferedOutputStream bos = new BufferedOutputStream( baos );			idr.setProperty( IDeviceRenderer.FILE_IDENTIFIER, bos );			idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER,					new EmptyUpdateNotifier( cm, gcs.getChartModel( ) ) );			gr.render( idr, gcs );			// cleanup the dataRow evaluator.			rowAdapter.close( );			// RETURN A STREAM HANDLE TO THE NEWLY CREATED IMAGE			try			{				bos.close( );				fis = new ByteArrayInputStream( baos.toByteArray( ) );			}			catch ( Exception ioex )			{				throw new ChartException( ChartReportItemPlugin.ID,						ChartException.GENERATION,						ioex );			}			if ( !"SVG".equals( sExtension ) && idr instanceof IImageMapEmitter ) //$NON-NLS-1$			{				imageMap = ( (IImageMapEmitter) idr ).getImageMap( );			}		}		catch ( BirtException ex )		{			if ( ex.getCause( ) instanceof ChartException					&& ( (ChartException) ex.getCause( ) ).getType( ) == ChartException.ZERO_DATASET )			{				// if the Data set has zero lines, just log the error and				// returns null gracefully.				logger.log( ex );				return null;			}			if ( ( ex.getCause( ) instanceof ChartException && ( (ChartException) ex.getCause( ) ).getType( ) == ChartException.INVALID_IMAGE_SIZE )					|| ( ex instanceof ChartException && ( (ChartException) ex ).getType( ) == ChartException.INVALID_IMAGE_SIZE ) )			{				// if the image size is invalid, this may caused by				// Display=None, lets ignore it.				logger.log( ex );				return null;			}			logger.log( ILogger.ERROR,					Messages.getString( "ChartReportItemPresentationImpl.log.onRowSetsFailed" ) ); //$NON-NLS-1$			logger.log( ex );			throw ex;		}		catch ( RuntimeException ex )		{			logger.log( ILogger.ERROR,					Messages.getString( "ChartReportItemPresentationImpl.log.onRowSetsFailed" ) ); //$NON-NLS-1$			logger.log( ex );			throw new ChartException( ChartReportItemPlugin.ID,					ChartException.GENERATION,					ex );		}		logger.log( ILogger.INFORMATION,				Messages.getString( "ChartReportItemPresentationImpl.onRowSetsEnd" ) ); //$NON-NLS-1$		if ( "SVG".equals( sExtension ) ) //$NON-NLS-1$		{			return fis;		}		else		{			return new Object[]{					fis, imageMap			};		}	}