Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 369889

Summary: BIRT Chart example for live data is using Generator.refresh() and Generator.build(). After fix only axes redraw, not the data.
Product: z_Archived Reporter: Chris Genly <genly>
Component: BIRTAssignee: Birt-Chart-inbox <Birt-Chart-inbox>
Status: RESOLVED WORKSFORME QA Contact: Xiaoying Gu <bluesoldier>
Severity: normal    
Priority: P3 CC: bluesoldier, guowei_ding
Version: 3.7.1   
Target Milestone: 4.4.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Chris Genly CLA 2012-01-26 21:29:24 EST
Build Identifier: Version: 3.7.1 M20110909-1335

My understanding is to speed up redraw of a chart, Generator.refresh() should be called instead of Generator.build(...).  But the examples call refresh and then build.  See the plugin org.eclipse.birt.chart.examples in the source folder org.eclipse.birt.chart.examples.api.viewer.SwtLiveChartViewer.

Note that after refresh is called, a redraw is done.  Redraw calls paintControl().  paintControl() always does a Generator.build().  Build() doesn't take the state updated by refresh, it just throws it away and rebuilds a whole new state (The variable gcs in the code below.)

From the example code:

private void chartRefresh( ){
  ...
  final Generator gr = Generator.instance( );
  scrollData( (ChartWithAxes) cm );
  // Refresh
  try {
    gr.refresh( gcs );
  } catch( ChartException ex ){
    ex.printStackTrace( );
  }
  redraw( );
  ...
}

---------------

I tried modifying the example so build() is only done the first time.  But in this case the axes redraw but the data does not.  The code below shows the modification I made.  The behavior of the modified example matches the behavior of the project I was working on where I discovered this problem.


public final void paintControl( PaintEvent e ) {
  Rectangle d = this.getClientArea( );
  if ( bFirstPaint ) {
	imgChart = new Image( this.getDisplay( ), d );
	gcImage = new GC( imgChart );
	idr.setProperty( IDeviceRenderer.GRAPHICS_CONTEXT, gcImage );
	bo = BoundsImpl.create( 0, 0, d.width, d.height );
	bo.scale( 72d / idr.getDisplayServer( ).getDpiResolution( ) );
  }
  Generator gr = Generator.instance( );
  try {
	if (bFirstPaint) //++++ added this line. But then data does not redraw.
	  gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, null, null );
	gr.render( idr, gcs );
	GC gc = e.gc;
	gc.drawImage( imgChart, d.x, d.y );
  } catch ( ChartException ce ){
	ce.printStackTrace( );
  }

  bFirstPaint = false;

  Display.getDefault( ).timerExec( 1, new Runnable( ) {
	public void run( ){
		chartRefresh( );
	}
  } );
}


Reproducible: Always

Steps to Reproduce:
1. Use Eclipse File/Import/plugins and fragments
2. Import org.eclipse.birt.chart.examples.
3. Run org.eclipse.birt.cahrt.examples.api.viewer.SwtLiveCharViewer.
4. Modify paintControl as shown above.
5. Rerun the example and notice the axes update, but the data does not.
Comment 1 Frank Ding CLA 2013-06-05 23:31:45 EDT
Recalculate data points for each series in Generator.refresh() method and fixed this problem.
Comment 2 Linda Chan CLA 2014-03-13 20:03:20 EDT
See #comment1.
If the issue still exists for you, please feel free to reopen the bug with more details on how to reproduce.