Visualize: Export with JSON and render
Export with JSON and render
HTML
<script src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/d3/3.4.8/d3.js"></script>
<script src="https://rawgit.com/zigfred/dimple/master/dist/dimple.v2.1.2tmp.js"></script>
<script src="http://localhost:8080/jasperserver-pro/client/visualize.js"></script>
<!--Provide container to render your visualization-->
<div id="container"></div>
JavaScript
visualize({
auth: {
name: "jasperadmin",
password: "jasperadmin",
organization: "organization_1"
}
}, function (v) {
report = v.report({
resource: "/public/Samples/Reports/AllAccounts",
success: exportJson,
error: errorHandler
});
});
function exportJson () {
report.export({
outputFormat: "json",
//pages: "1-5"
}, function (link, request) {
console.log(link);
window.open(link.href);
request({
dataType: "json"
})
.done(parseData)
.fail(errorHandler);
}, errorHandler);
}
function parseData(data) {
//console.log("result: ", data)
drawD3Chart(data);
}
function drawD3Chart (data) {
var width = 1100,
height = 700;
var svg = dimple.newSvg("#container", width, height);
var myChart = new dimple.chart(svg, data);
myChart.setBounds(75, 30, width-90, height-70);
myChart.addMeasureAxis("x", "store_cost");
var yAxis = myChart.addCategoryAxis("y", "store_sales")
var zAxis = myChart.addMeasureAxis("z", "unit_sales");
zAxis.overrideMax = 400;
myChart.addSeries("recyclable", dimple.plot.bubble);
myChart.addLegend(180, 10, 360, 20, "right");
myChart.draw();
cleanAxis(yAxis, 30)
}
function errorHandler(error) {
console.log(error);
}
function cleanYAxis(axis) {
}
var cleanAxis = function (axis, oneInEvery) {
// This should have been called after draw, otherwise do nothing
if (axis.shapes.length > 0) {
// Leave the first label
var del = false;
// If there is an interval set
if (oneInEvery > 1) {
// Operate on all the axis text
axis.shapes.selectAll("text")
.each(function (d) {
// Remove all but the nth label
if (del %...