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 2.2 - Access to reportContext in beforeDrawAxisLabel
cypherdj
Hi,<br />
<br />
I have a requirement to support various date formats across multiple reports, both in tables/crosstabs and charts. Obviously, BIRT provides default and custom formatting but I could not find a way to dynamically change this based on a report context property.<br />
<br />
We already pass the date-time format in the report context, and this can be retrieved at runtime using :<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getAppContext().get("DateFormat")
</pre>
<br />
This works fine for tables and crosstabs. The column binding is typed as String rather than Date, and we apply the formatting in the binding expression as:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
importPackage(Packages.java.text);
format = reportContext.getAppContext().get("DateFormat");
sdf = new SimpleDateFormat(format);
sdf.format(params["invoicedate"])
</pre>
<br />
However, I cannot figure out how to access the report context from within the beforeDrawAxisLabel method.<br />
<br />
Would anyone have faced a similar problem before and if so, how did you resolve the issue?<br />
<br />
Thanks,<br />
Cedric
Find more posts tagged with
Comments
johnw
Its either:
var reportContext = icsc.getExternalContext().getObject();
or its
var reportContext = icsc.getExternalContext().getScriptable();
I believe both will work.
cypherdj
Thank you John,
it worked like a charm,
Cedric
Chintan
Hello Michael,
As you suggested me that suppose
i changed y series label name then i have to go in to the script - > beforeDrawAxisLabel
I changed y series lagend name then i have to go in to the script - > beforeDrawLegendItem
What about if i want to change x series label ? which script i have to used.
All are using PGVs
for y axis i took plain PGV
for y series lagends i add "legends" to distinguish
i used x seris name as "xname".
Plesae guide me.
And also tell me from where i can check for which method which script i have to used?