Community
Participate
Working Groups
Build Identifier: 2.6.0.v20100429-1252 I'm trying to have dynamic time axis in BIRT line chart where user can select as input parameter if he wants to see the information from the last hour or from the last month, etc. When Unit of date/time grouping in Category X series is changed during runtime, this change affects only displayed axis's date/time labes but not the grouping of the displayed values. When this Unit is changed in design time also the grouping is affected. I tried to change unit of grouping in all events of chart but nothing helped. Reproducible: Always
Created attachment 174006 [details] report demonstrating the described issue
Created attachment 174007 [details] script required to create test table used by test report
RUN-TIME TEST CASE (fails): -run H2 database -run the attached script on H2 database -open the attached report -run the report -you can see that the report doesn't do any grouping on days or hours ... this is wrong behaviour, it should do!!! There is script on the chart which set the grouping during the run-time but this is not applied. DESING-TIME TEST CASE (works fine): -change the date/time grouping manually in the chart to Days -open the chart edit dialog -go to "Select Data" page -press button "Edit group and sorting" (on the right from Category (X) Series field) -the "Group and sorting" dialog is opened -change Unit of grouping to "Days" -confirm the group and sorting dialog -confirm the chart edit dialog -run the report again -now you can see that the grouping works ok
Hi Peter, It is unavailable to change group unit of chart model in chart's render script functions at runtime, because changing group unit of chart model will affect result of data query, but data query is executed before render script functions. I think you can change group unit of chart model in Report's onPrepare function. The sample scripts show below, I didn't validate these code, maybe minor error exists, please correct it. var chartItemHandle = reportContext.getDesignHandle().getElementByID(chartID); or var chartItemHandle = reportContext.getDesignHandle().findElement("chart item name"); if ( chartItemHandle instanceof ExtendedItemHandle ) { var chart = ((ExtendedItemHandle)chartItemHandle).getReportItem().getProperty("chart.instance"); importPackage(Packages.org.eclipse.birt.chart.model.attribute); var timeUnit = icsc.getExternalContext().getScriptable().getParameterValue("timeUnit") chart.getAxes().get(0).getSeriesDefinitions().get(0).getGrouping().setGroupingUnit( GroupingUnitType.getByName(timeUnit) );