Abid,
Can you please file a bugzilla entry regarding this issue. We will fix
it as soon as possible, since it's a freezing issue.
Thanks,
David
-----Original Message-----
From: birt-news-bounces@xxxxxxxxxxx
[mailto:birt-news-bounces@xxxxxxxxxxx] On Behalf Of Abid Hussain
Sent: Tuesday, May 22, 2007 4:41 PM
To: birt-news@xxxxxxxxxxx
Subject: Re: [birt-news] strange error when using chart engine
Hi again,
I forgot, I'm using the following versions:
org.eclipse.birt.chart.device.swt_2.1.1.v20070205-1728.jar
org.eclipse.birt.chart.engine_2.1.2.v20070205-1728.jar
org.eclipse.birt.chart.engine.extension_2.1.2.v20070205-1728.jar
The DeviceRenderer is obtained by:
final PluginSettings ps = PluginSettings.instance();
try {
deviceRenderer = ps.getDevice("dv.SWT");
} catch (ChartException pex) {
logger.error("Couldn't initialize renderer.", pex);
}
Best regards,
Abid
Abid Hussain schrieb:
Hi everybody,
I'm using the chart engine embedded in an eclipse plugin.
In this I create a line chart (ChartWithAxes) and I encounter a quite
strange behaviour. When the chart data values in the y-axis
approximate,
the chart generation freezes (which means it uses almost 100% of the
CPU).
I generate the data values from Points, like:
Point point1 = new Point(1179839372937l, 346.0);
pointList.add(point1);
Point point2 = new Point(1279839383156l, 340.0);
pointList.add(point2);
I can reproduce this error. When I decrease the second value of point2
to 330.0 (and below) everything works fine.
The same is when I put the second value to 350.0 it crashes, whereas
with 360.0 (and above) it works.
Anybody got an idea what to do?
Best regards,
Abid
The Chart is generated by this code:
public static final Chart createLineChart() {
ChartWithAxes lineChart = ChartWithAxesImpl.create();
// Plot
lineChart.getBlock().setBackground(ColorDefinitionImpl.WHITE());
Plot p = lineChart.getPlot();
p.getClientArea().setBackground(
ColorDefinitionImpl.create(255, 255, 225));
// Title
lineChart.getTitle().getLabel().getCaption().setValue("History");
// Legend
lineChart.getLegend().setVisible(false);
// X-Axis
Axis xAxisPrimary = lineChart.getPrimaryBaseAxes()[0];
// xAxisPrimary.setType(AxisType.TEXT_LITERAL);
xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL);
// xAxisPrimary.getMajorGrid().setTickCount(3);
xAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);
xAxisPrimary.getTitle().getCaption().setValue("Time");
xAxisPrimary.getTitle().setVisible(true);
// Y-Axis
Axis yAxisPrimary =
lineChart.getPrimaryOrthogonalAxis(xAxisPrimary);
yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL);
yAxisPrimary.getOrigin().setType(IntersectionType.VALUE_LITERAL);
//
yAxisPrimary.getTitle().getCaption().setValue(history.getModule());
yAxisPrimary.getTitle().getCaption().setValue("Battery");
yAxisPrimary.getTitle().setVisible(true);
Collection<Point> pointList = new ArrayList<Point>();
Point point1 = new Point(1179839372937l, 346.0);
pointList.add(point1);
Point point2 = new Point(1279839383156l, 340.0);
pointList.add(point2);
String[] xValues = new String[pointList.size()];
double[] yValues = new double[pointList.size()];
int j = 0;
for (Point point : pointList) {
xValues[j] = DateFormat.getDateTimeInstance().format(
new Date(point.getDate()));
yValues[j] = point.getValue();
j++;
}
logger.debug("Values (" + pointList + ") initialized.");
// Data Set
TextDataSet xDataSet = TextDataSetImpl.create(xValues);
NumberDataSet yDataSet = NumberDataSetImpl.create(yValues);
// X-Series
Series xSeries = SeriesImpl.create();
xSeries.setDataSet(xDataSet);
SeriesDefinition xSeriesDefinition =
SeriesDefinitionImpl.create();
xAxisPrimary.getSeriesDefinitions().add(xSeriesDefinition);
xSeriesDefinition.getSeries().add(xSeries);
// Y-Series
LineSeries ySeries = (LineSeries) LineSeriesImpl.create();
ySeries.setDataSet(yDataSet);
ySeries.getLineAttributes().setColor(ColorDefinitionImpl.CREAM());
for (int i = 0; i < ySeries.getMarkers().size(); i++) {
((Marker) ySeries.getMarkers().get(i))
.setType(MarkerType.RECTANGLE_LITERAL);
}
ySeries.getLabel().setVisible(true);
SeriesDefinition ySeriesDefinition =
SeriesDefinitionImpl.create();
ySeriesDefinition.getSeriesPalette().update(-2);
yAxisPrimary.getSeriesDefinitions().add(ySeriesDefinition);
ySeriesDefinition.getSeries().add(ySeries);
return lineChart;
}
The Chart is painted by this code (The line marked with '-->' lets the
application crash):
public void paintControl(PaintEvent e) {
Chart chart = createLineChart();
Rectangle rectangle = this.getClientArea();
Image imgChart = new Image(this.getDisplay(), rectangle);
GC gcImage = new GC(imgChart);
deviceRenderer.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT,
gcImage);
Bounds bounds = BoundsImpl.create(0, 0, rectangle.width,
rectangle.height);
bounds.scale(72d / deviceRenderer.getDisplayServer()
.getDpiResolution());
Generator generator = Generator.instance();
try {
--> gcs = generator.build(deviceRenderer.getDisplayServer(),
chart, bounds, null, null, null);
generator.render(deviceRenderer, gcs);
GC gc = e.gc;
gc.drawImage(imgChart, rectangle.x, rectangle.y);
} catch (ChartException gex) {
logger.error("Couldn't create chart.", gex);
}
}