VIsualize.js Render

by Pavel Savushchyk

HTML

<!--Provide URL to visualize.js-->
<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script src="http://localhost:8080/jasperserver-pro/client/visualize.js?_opt=false"></script>
<!--Provide container to render your visualization-->
<table>
    <tr valign="top">
        <td style="width:50%;">
            <div style="width:100%;" id="main"></div>
        </td>
        <td  style="width:50%;">
            <div style="width:100px;" id="drill-down"></div>
        </td>
    </tr>
</table>
<div>
    
    
    
</div>

CSS

#main{
   float: left; 
}

#drill-down{
    float: left; 
}

JavaScript

visualize({
    auth: {
        name: "jasperadmin",
        password: "jasperadmin",
        organization: "organization_1"
    }
}, function (v) {
      
    v("#main").report({
        resource: "/public/Samples/Reports/AccountList",
        defaultJiveUi: { enabled: true },
        linkOptions: {
            beforeRender: function (linkToElemPairs) {
                linkToElemPairs.forEach(showCursor);
            },
            events: {
                "click": function(ev, link){
                   if (link.type == "ReportExecution"){
                        v("#drill-down").report({
                            resource: link.parameters._report,
                            params: {
                                parStoreId: [link.parameters.parStoreId]
                            }, 
                        });     
                    }
                     console.log(link);
                }
            }    
        },
        error: function (err) {
            alert(err.message);
        }
    });
    
    function showCursor(pair){
           var el = pair.element;
               el.style.cursor = "pointer";
    }
    
});