Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Chart interactivity invoke scripts: how to dynamically generate a script(How to use chart interactivity invoke scripts in a portlet context)
Chart interactivity invoke scripts: how to dynamically generate a script [message #738454] Sun, 16 October 2011 08:43 Go to next message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Hi,

I use a Birt Portlet Viewer, so a report can be present several times on a same page, as showed on the attached image. Thus all birt report are generated with a portlet namespace, and it works pretty well. This portlet namespace is set to birt report context, so i can get it easily in my reports with:
namespace =reportContext.getAppContext().get("namespace"); 
.

My problem is when i try to use client-side invoke scripts for chart interactivity. As you can see in the attached image, when i click on a month a tooltip opens showing drill down information. I managed that in a similar manner to Jason's example on birtworld.blogspot.com "Calling Client Side JavaScript from a BIRT Chart" by just calling a javascript function in the invoke script:
myTooltipDrillDown(categoryData)


index.php/fa/4336/0/

But since i cant define namespace in this invoke script, it doesn't work when several instances of a report are aggregated on a same page: i can't specifiy which report should be affected by client-side code, in my example if i click on a month on the second report, it still displays tooltip on the first one. What i need to make it work is the possibility to dynamically insert my portlet namespace in this invoke script, something like JSP syntax:

myTooltipDrillDown(<%=reportContext.getAppContext().get("namespace")%>,categoryData)


Or build it on an event such beforeRendering, with an expression like:

mySerie.<Interactivity invoke script>= "myTooltipDrillDown('"+reportContext.getAppContext().get('namespace')+"', categoryData)"


I'm stuck on this problem i don't know if there is a way to manage that, any help would be much appreciated!

Thanks

[Updated on: Tue, 18 October 2011 10:46]

Report message to a moderator

Re: Chart interactivity invoke scripts: how to dynamically generate a script [message #739488 is a reply to message #738454] Mon, 17 October 2011 14:26 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If the invokeScript calls a script that you define in a text element in
the report you should be able to create client side variables at run
time that can be accessed in the script. Take a look at the attached
example.

Jason

On 10/16/2011 4:43 AM, dpardon wrote:
> Hi,
>
> I use a Birt Portlet Viewer, so a report can be present several times on a same page, as showed on the attached image. Thus all birt report are generated with the portlet namespace, and it works perfectly. This portlet namespace is set to birt report context, so i can get it easily in my reports with:
> namespace =reportContext.getAppContext().get("namespace"); .
>
> My problem is when i try to use client-side invoke scripts for chart interactivity. As you can see in the attached image, when i click on a month a smart tooltip opens showing drill down information. I managed that by just calling a js fonction in this invoke script:
> myTooltipDrillDown(categoryData)
>
> But since i cant precise namespace in this invoke script it doesn't work: if i click on a month on the second attached image's report, it still displays tooltip on the first one. What i need to make it work is the possibility to dynamically build a namespace in this invoke script, something like JSP syntax:
>
> myTooltipDrillDown(<%=reportContext.getAppContext().get("namespace")%>,categoryData)
>
> Or build it on an event such beforeRendering, with an expression like:
>
> mySerie.<Interactivity invoke script>= "myTooltipDrillDown('"+reportContext.getAppContext().get('namespace')+"', categoryData)"
>
> I'm stuck on this problem i don't know if there is a way to manage that, any help would be muck aprreciated!
>
> Thanks
>
Re: Chart interactivity invoke scripts: how to dynamically generate a script [message #740238 is a reply to message #739488] Tue, 18 October 2011 09:49 Go to previous messageGo to next message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Thanks for your response. To try to clarify this very tough issue, i updated my case with your report example. I just added title and coefficient parameters on your example to distinguish report instances on liferay: as you can see on attached image , a coeff 10 is applied on dataset for the report on the right.

index.php/fa/4401/0/

If i click on item2 for left report, i get an alertbox with '65', which is the correct answer. For report on the right i get '65' too, whereas i should get '650'. If i refresh only the coeff 10 portlet (report on the right), this time when i click on item2 i get '650' for both reports. And if i refresh only the portlet Coeff 1, both reports return '65' again. I hope this explanation makes sense Smile

This behavior seems normal since in this example we should namespace javascript function 'ShowEventData' to make it work as expected. But if we can't generate dynamically the invoke script, unless i misunderstood anything, it doesnt seem possible to use this namespace, that was my problem in my original post.

i think i found a workaround to make this invokescript dynamic. Nevertheless, as i was working on your example i discovered Birt defines the same internal function ID for the 2 invokescripts Sad That seems to be the end of the way for my drill down tooltip feature. Here is the code generated in liferay's page for the invoke scripts attached example:

<Script>function userCallBack1318885099(evt,categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel)
  {ShowEventData(evt, categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel);
};
</Script>
...
<Script>
  function userCallBack1318885099(evt,categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel)
  {ShowEventData(evt, categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel);};
</Script>


It doesnt look to take into consideration namespace option: with this HTMLRenderOption API,
outputOptions.setHTMLIDNamespace(response.getNamespace());

Birt perfectly namespaces every html elements except this one Sad(( I don't know if it is a bug or a normal behavior.







[Updated on: Tue, 18 October 2011 12:00]

Report message to a moderator

Re: Chart interactivity invoke scripts: how to dynamically generate a script [message #740490 is a reply to message #740238] Tue, 18 October 2011 15:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

That does sound like a bug.

Jason

On 10/18/2011 5:49 AM, dpardon wrote:
> Thanks for your response. To try to clarify this very tough issue, i updated my case with your report example. I just added title and coefficient parameters on your example to distinguish report instances on liferay: as you can see on attached image , a coeff 10 is applied on dataset for the report on the right.
>
>
>
> If i click on item2 for left report, i get an alertbox with '65', which is the correct answer. For report on the right i get '65' too, whereas i should get '650'. If i refresh only the coeff 10 portlet (report on the right), this time when i click on item2 i get '650' for both reports. I hope this explanation makes sense :)
>
> This behavior seems normal since in this example we should namespace javascript function 'ShowEventData' to make it work as expected. But if we can't generate dynamically the invoke script, unless i misunderstood anything, it doesnt seem possible to use this namespace, that was my problem in my original post.
>
> i think i found a workaround to make this invokescript dynamic. Nevertheless, as i was working on your example i nearly had a heart attack when i saw Birt defines the same internal function ID for the 2 invokescripts :( Here is the code generated in liferay's page for the invoke scripts attached example:
>
>
> <Script>function userCallBack1318885099(evt,categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel)
> {ShowEventData(evt, categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel);
> };
> </Script>
> ...
> <Script>
> function userCallBack1318885099(evt,categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel)
> {ShowEventData(evt, categoryData, valueData, valueSeriesName, legendItemText, legendItemValue, axisLabel);};
> </Script>
>
>
> It doesnt look to take into consideration namespace option: with this HTMLRenderOption API, outputOptions.setHTMLIDNamespace(response.getNamespace());
> Birt perfectly namespaces every html elements except this one :((( I don't know if it is a bug or a normal behavior.
>
>
>
>
>
>
>
>
>
>
Re: Chart interactivity invoke scripts: how to dynamically generate a script [message #740619 is a reply to message #740490] Tue, 18 October 2011 18:07 Go to previous message
donino donino is currently offline donino doninoFriend
Messages: 183
Registered: July 2011
Senior Member
Thanks for your time. I logged this issue on bugzilla as Bug 361285.
Previous Topic:Malformed input while loading data set cache
Next Topic:webservice error
Goto Forum:
  


Current Time: Fri Apr 19 05:37:51 GMT 2024

Powered by FUDForum. Page generated in 0.01968 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top