Improve drawing speed [message #490941] |
Mon, 12 October 2009 14:06 |
Olivier Cailloux Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hello,
I have performances issues with BIRT charting engine when displaying too
many points (e.g., three series of data of 400 points each on the same
graph). I want to display the data in real-time, and the data is from
time series, so at each second, or so, the graph should re-draw (on an
SWT panel), with all the data points changed. The structure of the graph
however does not change. As it has to be re-drawn each second, and the
drawing currently takes about 600 ms, the user interface feels really
not responsive. Not to mention what will happen if the user has a slower
PC than mine, or I want to display several charts at the same time on
the screen... I'd like to find some ways to speed up the drawing. I feel
it should be possible, because 600 ms to draw a graphic with about 1000
points seems too much on a modern computer, IMHO.
In particular, I read that it is possible to only refresh the graph
instead of re-generating it completely
[ http://wiki.eclipse.org/BIRT/FAQ/Charts2.2#How_do_I_create_a _chart_and_perform_a_minimal_refresh_to_show_updated_scrolli ng_data_values_using_animation.3F].
But that does not work for me (explanations here below)...
The series are line series without markers, created like this.
---
final LineSeries hrSeries = (LineSeries) LineSeriesImpl.create();
hrSeries.getLineAttributes().setColor(ColorDefinitionImpl.GR EEN());
hrSeries.getMarkers().clear();
final SeriesDefinition hrSeriesDefs = SeriesDefinitionImpl.create();
hrSeriesDefs.getSeries().add(hrSeries);
yAxis.getSeriesDefinitions().add(hrSeriesDefs);
---
I have the data series in the form of Collections. I inject the data
into the charting engine ChartWithAxes using the following code style.
---
List<Double> dataPoints;
DataSet yDataSet = NumberDataSetImpl.create(dataPoints);
Axis yAxisPrimary = ...;
SeriesDefinition sd0 = yAxisPrimary.getSeriesDefinitions().get(0);
sd0.getSeries().get(0).setDataSet(yDataSet);
---
Then draw the graph in the paint event of my SWT widget using the
following code.
---
// initialized only once.
IDeviceRenderer m_deviceRenderer = new SwtRendererImpl();
public void paintChart(final GC gc, final Rectangle re) {
m_deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEX T, gc);
final Bounds bo = BoundsImpl.create(drawArea.x, drawArea.y,
drawArea.width, drawArea.height);
final int dpiFromBirt =
m_deviceRenderer.getDisplayServer().getDpiResolution();
bo.scale(72d / dpiFromBirt);
GeneratedChartState generated =
Generator.instance().build(m_deviceRenderer.getDisplayServer (), chart,
bo, null);
Generator.instance().render(m_deviceRenderer, generated);
---
Generating the graph takes about 300 ms, then rendering it takes another
300 ms. (That is excluding the time to create the dataset, which is
negligible in comparison.)
I tried to refresh the previously generated instance instead of
re-building it, then rendering it.
---
Generator.instance().refresh(m_generated);
Generator.instance().render(m_deviceRenderer, m_generated);
---
That is by far faster, but that does not show a refreshed graph. I guess
the problem is that the charting engine does not know that I have
changed the dataset meanwhile (with the code above).
I also tried to paint on an image (painting on gcImage instead of gc,
with the code below), then displaying the image, but that is not faster.
---
Image imgChart = new Image(gc.getDevice(), re);
GC gcImage = new GC(imgChart);
---
How can I use refresh() instead of build()? Is there something else I
could do to improve the drawing speed? Thanks a lot.
Olivier
|
|
|
|
Powered by
FUDForum. Page generated in 0.03290 seconds