Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319386 - runtime change of date/time grouping doesn't work
Summary: runtime change of date/time grouping doesn't work
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Heng Li CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-09 09:31 EDT by Peter Rafaj CLA
Modified: 2013-03-11 05:28 EDT (History)
2 users (show)

See Also:


Attachments
report demonstrating the described issue (120.27 KB, application/octet-stream)
2010-07-12 06:13 EDT, Peter Rafaj CLA
no flags Details
script required to create test table used by test report (650 bytes, text/x-sql)
2010-07-12 06:14 EDT, Peter Rafaj CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Rafaj CLA 2010-07-09 09:31:17 EDT
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
Comment 1 Peter Rafaj CLA 2010-07-12 06:13:51 EDT
Created attachment 174006 [details]
report demonstrating the described issue
Comment 2 Peter Rafaj CLA 2010-07-12 06:14:47 EDT
Created attachment 174007 [details]
script required to create test table used by test report
Comment 3 Peter Rafaj CLA 2010-07-12 06:25:46 EDT
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
Comment 4 Heng Li CLA 2013-03-11 05:28:10 EDT
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)
     );