tag:blogger.com,1999:blog-16506996.post1888659312812755649..comments2024-02-08T01:57:07.944-07:00Comments on The Digital Voice: BIRT: Get Access to Chart Element and Modify Properties from ReportRunnable in BIRT 2.5John Wardhttp://www.blogger.com/profile/10741149622435353727noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-16506996.post-29984406554036267262011-07-18T03:06:57.283-06:002011-07-18T03:06:57.283-06:00Thank you very much for sharing this.
You make me...Thank you very much for sharing this.<br /><br />You make me win a lot of time.Roxannenoreply@blogger.comtag:blogger.com,1999:blog-16506996.post-27158385356895295192010-01-28T07:01:01.795-07:002010-01-28T07:01:01.795-07:00The code works perfect :) . You are a true BIRT Ev...The code works perfect :) . You are a true BIRT Evangelist. Thanks a lot. I hope I get to work under someone like you in the future.<br /><br />Now one last query (And i promise its the last doubt ;) )<br /><br />I want to change the subtype of the chart. So at design time I have a Bar graph with subtype as "Side-by-side". Now I want to change it to "Percent Stacked" at runtime through Java code. <br /><br />I tried with cwaBar.setSubType( "Percent Stacked" ); but it ofcourse didnt work since I am sure I need to set a few more parameters which I am not sure of.<br /><br />Thanks in advance,<br /><br />KiranKiran Vaidyahttps://www.blogger.com/profile/04959868461755803879noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-62964501492945282032010-01-28T02:45:30.431-07:002010-01-28T02:45:30.431-07:00Basically, what is happening is that 3D charts req...Basically, what is happening is that 3D charts require particular formatting, separate from 2d charts. 3D charts require an additional axis that is not required in 2D charts. You will want to check your chart type, and if it is 3D, use something like the following to format the axis correctly:<br /><br />//get chart element handle called "PieChart"<br /> ExtendedItemHandle eih = (ExtendedItemHandle) design.getDesignHandle()<br /> .getDesignHandle().findElement("PieChart");<br /> <br /> //get the actual chart instance since Charts are extended item handles<br /> ChartWithAxes cwaBar = (ChartWithAxes) eih.getReportItem().getProperty(<br /> "chart.instance");<br /> <br /> //set title of chart to New Label<br /> cwaBar.getTitle().getLabel().getCaption().setValue("New Label");<br /> <br /> //set 2d with depth<br /> cwaBar.setDimension(ChartDimension.THREE_DIMENSIONAL_LITERAL);<br /> <br /> // X-Axis<br /> Axis xAxisPrimary = cwaBar.getPrimaryBaseAxes( )[0];<br /> xAxisPrimary.setType( AxisType.TEXT_LITERAL );<br /> xAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );<br /> xAxisPrimary.getOrigin( ).setType( IntersectionType.MIN_LITERAL );<br /><br /> // Y-Axis<br /> Axis yAxisPrimary = cwaBar.getPrimaryOrthogonalAxis( xAxisPrimary );<br /> yAxisPrimary.getMajorGrid( ).setTickStyle( TickStyle.LEFT_LITERAL );<br /> yAxisPrimary.setType( AxisType.LINEAR_LITERAL );<br /> yAxisPrimary.getLabel( ).getCaption( ).getFont( ).setRotation( 90 );<br /> <br /> // Z-Axis<br /> Axis zAxis = AxisImpl.create( Axis.ANCILLARY_BASE );<br /> zAxis.setType( AxisType.TEXT_LITERAL );<br /> zAxis.setLabelPosition( Position.BELOW_LITERAL );<br /> zAxis.setTitlePosition( Position.BELOW_LITERAL );<br /> zAxis.getMajorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL );<br /> zAxis.setOrientation( Orientation.HORIZONTAL_LITERAL );<br /> xAxisPrimary.getAncillaryAxes( ).add( zAxis );John Wardhttps://www.blogger.com/profile/10741149622435353727noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-504895821684215692010-01-28T02:24:07.648-07:002010-01-28T02:24:07.648-07:00However when changing the chart to 3D its throwing...However when changing the chart to 3D its throwing a runtime exception and I can only view a blank chart<br /><br />Seems to be a bug in Birt Charts<br /><br />Since I am using a Bar Graph I have casted the ExtendedItemHandle object as a Chart Object (also works with ChartWithAxesImpl and ChartWithAxes)<br /><br />ExtendedItemHandle eih = (ExtendedItemHandle) design.getDesignHandle().getDesignHandle().findElement("NewChart");<br /><br />ChartWithAxes cwa = (ChartWithAxes) eih.getReportItem().getProperty(<br />"chart.instance"); //You can use Chart or ChartWithAxesImpl as well<br />cwa.setDimension(ChartDimension.THREE_DIMENSIONAL_LITERAL);<br /><br /><br />It throws a runtime exception as<br />org.eclipse.birt.chart.exception.ChartException<br />at org.eclipse.birt.chart.factory.Generator.build(Generator.java:1020)<br />at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.buildChart(ChartReportItemPresentationBase.java:926)<br />at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.onRowSets(ChartReportItemPresentationBase.java:799)<br />at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationProxy.onRowSets(ChartReportItemPresentationProxy.java:116)<br />at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:964)<br />at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localizeForeign(LocalizedContentVisitor.java:553)<br />at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localize(LocalizedContentVisitor.java:161)<br />at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:37)<br />at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)<br />at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90)<br />at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)<br />at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:170)<br />at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)Kiran Vaidyahttps://www.blogger.com/profile/04959868461755803879noreply@blogger.comtag:blogger.com,1999:blog-16506996.post-90514423853485313632010-01-28T02:21:43.480-07:002010-01-28T02:21:43.480-07:00Hi John,
Thanks a million for posting the blog. I...Hi John,<br /><br />Thanks a million for posting the blog. Its working perfectly fine.<br />God bless u for ur prompt reply as well as posting it as a blog so that other users facing similar issues will also get quick help.<br /><br />Regards,<br />KiranKiran Vaidyahttps://www.blogger.com/profile/04959868461755803879noreply@blogger.com