|
Re: Set data set programatically [message #529642 is a reply to message #529419] |
Mon, 26 April 2010 15:31 |
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03103 seconds