Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Set data set programatically(Setting dataset in program)
Set data set programatically [message #529419] Sun, 25 April 2010 05:04 Go to next message
laxmipathi raju is currently offline laxmipathi rajuFriend
Messages: 17
Registered: April 2010
Junior Member
Hi,
I am creating charts dynamically.I am setting data set as follows.

ElementFactory ef = designHandle.getElementFactory( );
ExtendedItemHandle extendedItemHandle =
ef.newExtendedItem( null, "Chart" );
try{
extendedItemHandle.getReportItem( ).setProperty( "chart.instance",newChart );
} catch( ExtendedElementException e )
{
e.printStackTrace( );
}
// Get an ODA data set and bind it to the chart
OdaDataSetHandle dataSet = ( OdaDataSetHandle )
designHandle.getDataSets( ).get( 0 );
try {
extendedItemHandle.setDataSet( dataSet );

extendedItemHandle.setHeight( "250pt" );
extendedItemHandle.setWidth( "400pt" );
} catch ( SemanticException e ) {
e.printStackTrace( );
}

But when i open the saved rptdesign file in birt (->Edit chart)i am getting the following error
" Column binding "row["Year"]" has referred to a binding "Year" which does not exist."

It is not setting dataset properly.

can anybody send proper setting of data set programatically.


Thank You,
Laxmipathi raju

Re: Set data set programatically [message #529642 is a reply to message #529419] Mon, 26 April 2010 15:31 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You have to create the bindings on the chart. This is the mapping to
the dataset.

ExtendedItemHandle eih = designFactory.newExtendedItem (
null,"Chart" );
ComputedColumn cs1=null, cs2=null;
try
{
eih.setHeight( "175pt" );//$NON-NLS-1$
eih.setWidth( "450pt" );//$NON-NLS-1$
eih.setProperty ( ExtendedItemHandle.DATA_SET_PROP,
"ChartData");//$NON-NLS-1$
eih.setProperty("outputFormat", "PNG");

PropertyHandle cs = eih.getColumnBindings();
cs1 = StructureFactory.createComputedColumn();
cs2 = StructureFactory.createComputedColumn();
cs1.setName("xaxis");
cs1.setDataType("string");
cs2.setName("yaxis");
cs2.setDataType("float");

cs1.setExpression("dataSetRow[\"xaxis\"]");
cs2.setExpression("dataSetRow[\"yaxis\"]");
cs.addItem(cs1);
cs.addItem(cs2);
}
catch ( SemanticException e )
{
e.printStackTrace( );
}

Jason

On 4/25/2010 1:05 AM, laxmipathi raju wrote:
> Hi,
> I am creating charts dynamically.I am setting data set as follows.
>
> ElementFactory ef = designHandle.getElementFactory( );
> ExtendedItemHandle extendedItemHandle =
> ef.newExtendedItem( null, "Chart" );
> try{
> extendedItemHandle.getReportItem( ).setProperty(
> "chart.instance",newChart );
> } catch( ExtendedElementException e )
> {
> e.printStackTrace( );
> }
> // Get an ODA data set and bind it to the chart
> OdaDataSetHandle dataSet = ( OdaDataSetHandle )
> designHandle.getDataSets( ).get( 0 );
> try {
> extendedItemHandle.setDataSet( dataSet );
>
> extendedItemHandle.setHeight( "250pt" );
> extendedItemHandle.setWidth( "400pt" );
> } catch ( SemanticException e ) {
> e.printStackTrace( );
> }
>
> But when i open the saved rptdesign file in birt (->Edit chart)i am
> getting the following error
> " Column binding "row["Year"]" has referred to a binding "Year" which
> does not exist."
>
> It is not setting dataset properly.
>
> can anybody send proper setting of data set programatically.
>
>
> Thank You,
> Laxmipathi raju
>
Previous Topic:To load the report in the same page
Next Topic:OSX cocoa PDF print and save not functioning from within WebViewer
Goto Forum:
  


Current Time: Wed Apr 24 15:39:20 GMT 2024

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

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

Back to the top