I want to show jFreeChart generated SVG grapics in my JSP portlet. The size of the image should be as wide as the portlet and the height a fixed factor of the width.
I solved the problem but I wonder if there is a better way to accomplish the same task.
What I do:
Define an invisibel element to find the portlet after rendering
<div id="<%= myPortletNamespace %>test" style="display: none;"></div>
Define a trigger which fires when rendering is complete and the width of my portlet is set. Here I find the afore mentioned element, check it's size, resize the table containing the graphic and make a resource call to get the graphic.
Liferay.on('allPortletsReady', function() { AUI().use('node', function(A) { var test = A.one('#<%= myPortletNamespace %>test'); var parent = test.ancestor('.portlet-body');; if (parent != null){ var table_width = parent.get('offsetWidth');; <%= myResize %>(table_width); <%= myGetTableCharts %>(); } }); } );
One problem is the trigger seems to fire three times which might become a performance problem.
Any better way to do this ?