Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » NaN problem when creating a chart
NaN problem when creating a chart [message #480046] Thu, 13 August 2009 14:48 Go to next message
Maarten Laurs is currently offline Maarten LaursFriend
Messages: 7
Registered: August 2009
Junior Member
When I insert Double.NaN as a value in a Y axis array (Double[ ]) I get an empty value at that point, which is great because that's what I was looking for.

But I would like to have that empty value at the lowest value of the Y axis, and if I insert NaN as the first value in the array the chart engine returns a garbled graph. Sad

Bugzilla comes back with "Zarro Boogs found", so I am assuming this hasn't been noticed before. Am I right? Just want to make sure I'm not addressing any known issues here.
Re: NaN problem when creating a chart [message #480128 is a reply to message #480046] Thu, 13 August 2009 23:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Maarten,

What version of BIRT and can you post the code?

Jason

Maarten Laurs wrote:
> When I insert Double.NaN as a value in a Y axis array (Double[ ]) I get
> an empty value at that point, which is great because that's what I was
> looking for.
>
> But I would like to have that empty value at the lowest value of the Y
> axis, and if I insert NaN as the first value in the array the chart
> engine returns a garbled graph. :(
> Bugzilla comes back with "Zarro Boogs found", so I am assuming this
> hasn't been noticed before. Am I right? Just want to make sure I'm not
> addressing any known issues here.
Re: NaN problem when creating a chart [message #480218 is a reply to message #480046] Fri, 14 August 2009 12:27 Go to previous messageGo to next message
Maarten Laurs is currently offline Maarten LaursFriend
Messages: 7
Registered: August 2009
Junior Member
Thanks for taking a look at this, Jason.

I am using BIRT 2.3.2

The example I wrote will show you the issue, but the code isn't self contained. You will need to take the output (an BIRT ChartWithAxis) and put it on a canvas. I assume this is not a problem, but let me know if i am mistaking about this.

If you replace Double.NaN in line 17 for some double value the output will show a nice graph.

public class ChartWithAxes {
	public final Chart createCurveFittingLine() {

		ChartWithAxes cwaLine = ChartWithAxesImpl.create();
		cwaLine.setType("Mixed Chart");
		cwaLine.setSubType("Overlay");
		cwaLine.getLegend().setVisible(false);

		Axis xAxisPrimary = cwaLine.getPrimaryBaseAxes()[0];
		xAxisPrimary.setType(AxisType.LINEAR_LITERAL);

		Axis yAxisPrimary = cwaLine.getPrimaryOrthogonalAxis(xAxisPrimary);
		yAxisPrimary.setType(AxisType.LINEAR_LITERAL);

		NumberDataSet xValuesPrimary = NumberDataSetImpl.create(new Double[] { 1d, 2d, 3d });
		NumberDataSet yValuesPrimary = NumberDataSetImpl
				.create(new Double[] { Double.NaN, 1d, 3d });

		Series seCategory = SeriesImpl.create();
		LineSeries ls = (LineSeries) LineSeriesImpl.create();

		seCategory.setDataSet(xValuesPrimary);
		ls.setDataSet(yValuesPrimary);

		SeriesDefinition sdXp = SeriesDefinitionImpl.create();
		SeriesDefinition sdYp = SeriesDefinitionImpl.create();

		xAxisPrimary.getSeriesDefinitions().add(sdXp);
		yAxisPrimary.getSeriesDefinitions().add(sdYp);

		sdXp.getSeries().add(seCategory);
		sdYp.getSeries().add(ls);

		ls.setCurve(true);

		return cwaLine;
	}
}
Re: NaN problem when creating a chart [message #480263 is a reply to message #480218] Fri, 14 August 2009 15:14 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Maarten,

This should work. Please log a bug for this. I tried in 2.5 as well
with the same issue. As a work around can you do this

> NumberDataSet yValuesPrimary = NumberDataSetImpl
> .create(new Double[] { Double.NaN, 1d, 3d });

to

NumberDataSet yValuesPrimary = NumberDataSetImpl
.create(new Double[] { null, 1d, 3d });
Jason


Maarten Laurs wrote:
> Thanks for taking a look at this, Jason.
>
> I am using BIRT 2.3.2
>
> The example I wrote will show you the issue, but the code isn't self
> contained. You will need to take the output (an BIRT ChartWithAxis) and
> put it on a canvas. I assume this is not a problem, but let me know if i
> am mistaking about this.
> If you replace Double.NaN in line 17 for some double value the output
> will show a nice graph.
>
>
> public class ChartWithAxes {
> public final Chart createCurveFittingLine() {
>
> ChartWithAxes cwaLine = ChartWithAxesImpl.create();
> cwaLine.setType("Mixed Chart");
> cwaLine.setSubType("Overlay");
> cwaLine.getLegend().setVisible(false);
>
> Axis xAxisPrimary = cwaLine.getPrimaryBaseAxes()[0];
> xAxisPrimary.setType(AxisType.LINEAR_LITERAL);
>
> Axis yAxisPrimary = cwaLine.getPrimaryOrthogonalAxis(xAxisPrimary);
> yAxisPrimary.setType(AxisType.LINEAR_LITERAL);
>
> NumberDataSet xValuesPrimary = NumberDataSetImpl.create(new
> Double[] { 1d, 2d, 3d });
> NumberDataSet yValuesPrimary = NumberDataSetImpl
> .create(new Double[] { Double.NaN, 1d, 3d });
>
> Series seCategory = SeriesImpl.create();
> LineSeries ls = (LineSeries) LineSeriesImpl.create();
>
> seCategory.setDataSet(xValuesPrimary);
> ls.setDataSet(yValuesPrimary);
>
> SeriesDefinition sdXp = SeriesDefinitionImpl.create();
> SeriesDefinition sdYp = SeriesDefinitionImpl.create();
>
> xAxisPrimary.getSeriesDefinitions().add(sdXp);
> yAxisPrimary.getSeriesDefinitions().add(sdYp);
>
> sdXp.getSeries().add(seCategory);
> sdYp.getSeries().add(ls);
>
> ls.setCurve(true);
>
> return cwaLine;
> }
> }
>
Re: NaN problem when creating a chart [message #480436 is a reply to message #480263] Mon, 17 August 2009 07:18 Go to previous message
Maarten Laurs is currently offline Maarten LaursFriend
Messages: 7
Registered: August 2009
Junior Member
Thanks for the null suggestion. With some modifications to the code this resolves the issue for me Smile

If filed the bug under https://bugs.eclipse.org/bugs/show_bug.cgi?id=286758.
Previous Topic:IResultSetMetaData / IColumnMetaData
Next Topic:$100 USD Amazon gift certificate in exchange for your ideas and experiences related to BIRT!
Goto Forum:
  


Current Time: Sat May 11 00:57:43 GMT 2024

Powered by FUDForum. Page generated in 0.03243 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top