| 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: | BIRT | Assignee: | 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: | |||
Recalculate data points for each series in Generator.refresh() method and fixed this problem. |
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.