Visualize: Report+controls

Test plugins

by Yuriy Bablyukh

HTML

<!--Provide URL to visualize.js-->
<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:80%">
      <div id="container"></div>
    </td>
    <td style="width:20%">
      <div id="inputContainer">
        <input type="button" value="Export" id="export" />

      </div>
    </td>
  </tr>
</table>

JavaScript

visualize({
  auth: {
    name: "jasperadmin",
    password: "jasperadmin",
    organization: "organization_1"
  }
}, function(v) {


  var report = v.report({
    resource: "/public/Samples/Reports/10g.PerformanceByStoreType",
    container: "#container",
    error: function(err) {
      console.error(err);
    }
  });

  $("#export").click(function() {

    alert("Handler for .click() called.");
    report["export"]({
      outputFormat: "json"
    }, function(link) {
      console.log(link);
      window.location.href = link.href ? link.href : link;
    }, function(err) {
      console.error(err);
    });
  });


});