VIsualize.js Render
by Yuriy Bablyukh
HTML
<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>
<div>
<div style="width:830px;" id="main"></div>
<div style="width:500px;" id="drill-down"></div>
</div>
CSS
#main{
float: left;
}
#drill-down{
float: left;
}
JavaScript
visualize({
auth: {
name: "jasperadmin",
password: "jasperadmin",
organization: "organization_1"
}
}, function (v) {
v("#main").dashboard({
resource: "/public/New_Dashboard",
linkOptions: {
beforeRender: function (linkToElemPairs) {
linkToElemPairs.forEach(showCursor);
},
events: {
"click": function(ev, link){
console.dir(link);
if (link.type == "ReportExecution") {
if ("city" in link.parameters) {
console.dir(link.parameters.country);
v("#drill-down").report({
resource: link.parameters._report,
params: {
city: [link.parameters.city],
country:link.parameters.country
}
});
}
}
}
}
},
error: function (err) {
alert(err.message);
}
});
function showCursor(pair){
var el = pair.element;
el.style.cursor = "pointer";
}
});