Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
BIRT runtime dynamic chart scaling
mantisa
Hi, I'm writting a composite report engine that allows users to select some reports and render them as one, merging all HTML outputs for each sub-report in the same HTML file, reducing charts size. The issue is how to resize charts before rendering the sub-report without lossing image quality.
I tried something like this:
ReportDesignHandle reportHandle = (ReportDesignHandle) runnable.getDesignHandle();
ReportItemHandle handle = (ReportItemHandle) reportHandle.findElement("NewChart");
handle.setWidth("6in");
handle.setHeight("4in");
But the generated image output has a sensible loss of quality.
Does anybody know another way?
Find more posts tagged with
Comments
mantisa
Hi, I have solved this problem by my self. For example, this code resizes the chart to a half:
ReportDesignHandle reportHandle = (ReportDesignHandle) runnable.getDesignHandle();
ReportItemHandle handle = (ReportItemHandle) reportHandle.findElement("NewChart");
ExtendedItemHandle eHandle = (ExtendedItemHandle) handle;
ChartWithAxes chart = (ChartWithAxes) eHandle.getReportItem().getProperty("chart.instance");
double oldWidth = chart.getBlock().getBounds().getWidth();
double oldHeight = chart.getBlock().getBounds().getHeight();
chart.getBlock().getBounds().setWidth(oldWidth / 2);
chart.getBlock().getBounds().setHeight(oldHeight / 2);
handle.setWidth(handle.getWidth().getMeasure() / 2);
handle.setHeight(handle.getHeight().getMeasure() / 2);
Note that you also need to resize all the parent elements of the chart (for example grid cells) and the property bounds is only neccesary (and avaliable) in charts.