Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 159970 - Not able to change the chart size using event handlers
Summary: Not able to change the chart size using event handlers
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 2.2.0 RC0   Edit
Assignee: Yulin Wang CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-06 01:48 EDT by Gayatri Bora CLA
Modified: 2007-05-30 23:38 EDT (History)
3 users (show)

See Also:


Attachments
Bar chart with less data (98.85 KB, image/jpeg)
2006-10-06 02:42 EDT, Gayatri Bora CLA
no flags Details
Bar chart with more data (98.80 KB, image/jpeg)
2006-10-06 02:46 EDT, Gayatri Bora CLA
no flags Details
Pie chart with less data (112.73 KB, image/jpeg)
2006-10-06 03:08 EDT, Gayatri Bora CLA
no flags Details
Pie chart with more data (146.97 KB, image/jpeg)
2006-10-06 03:09 EDT, Gayatri Bora CLA
no flags Details
Please use this report to test if script works (32.93 KB, application/octet-stream)
2007-05-30 23:34 EDT, Yulin Wang CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gayatri Bora CLA 2006-10-06 01:48:13 EDT
In my report, I have a chart whose size I want to control from script. I am using context.getChartInstance().getBlock().getBounds().setHeight(900) function in chart's before rendering(). It seems if I give the numeric value less than the chart's original size, the chart appears distorted and the text-size gets increased. On the other hand if I give larger numeric values, the chart gets compressed.

The same function when written in before generation method does not show any change in the chart's height.
Comment 1 Gayatri Bora CLA 2006-10-06 02:38:29 EDT
I would like to redraw the graph with lesser or larger size depending on the dataset.

Attaching for your reference how the static size affects the chart for smaller and larger amount of data in the next comment.
Comment 2 Gayatri Bora CLA 2006-10-06 02:42:23 EDT
Created attachment 51514 [details]
Bar chart with less data
Comment 3 Gayatri Bora CLA 2006-10-06 02:46:26 EDT
Created attachment 51515 [details]
Bar chart with more data
Comment 4 Gayatri Bora CLA 2006-10-06 03:08:05 EDT
Created attachment 51516 [details]
Pie chart with less data
Comment 5 Gayatri Bora CLA 2006-10-06 03:09:23 EDT
Created attachment 51517 [details]
Pie chart with more data
Comment 6 David Michonneau CLA 2007-04-03 15:29:15 EDT
The size is set in the ROM (extendeditemhandle), so changing it in the chart 
only will not modify the size reserved for rendering, although the chart engine 
will use this new size to render the chart. Hence the distortion.

So a better option would be to change the size of the extendeditem in the rom 
in another scripting method, we will do some testing and post instructions how 
to do it here.
Comment 7 Yulin Wang CLA 2007-05-16 01:07:40 EDT
User could write simple API code to resize charts. 
This is how:
1. open "script" tab and click the root node (report name) in outline view
2. select "beforeFactory" method in editor's combo
3. write code like this: this.getReportElement(CHART_NAME).setHeight("400pt")
Note that some relative dimension units like "px" or "%" are not supported here.

Fixed by overriding IReportItem methods to update internal chart size when resizing extended item.
Comment 8 Krishna Venkatraman CLA 2007-05-30 14:17:26 EDT
A workaround was proposed. This was not working properly and was throwing an error saying ""

There are errors evaluating script

"this.getReportElement("barchart").setHeight("400pt");
this.getReportElement("barchart").setWidth("1500pt ")".


TypeError: setHeight is not a function.

any idea?
Comment 9 Yulin Wang CLA 2007-05-30 23:34:11 EDT
Created attachment 69447 [details]
Please use this report to test if script works
Comment 10 Yulin Wang CLA 2007-05-30 23:38:25 EDT
I just tested 2.2RC0 build. It works. Please use attached report to test.