Community
Participate
Working Groups
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.
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.
Created attachment 51514 [details] Bar chart with less data
Created attachment 51515 [details] Bar chart with more data
Created attachment 51516 [details] Pie chart with less data
Created attachment 51517 [details] Pie chart with more data
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.
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.
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?
Created attachment 69447 [details] Please use this report to test if script works
I just tested 2.2RC0 build. It works. Please use attached report to test.