Chart View - REST API integration

General API usage

by godgav

HTML

<div id="dataView">
    <div id="dataSelector"></div>
    <div id="typeChooser"></div>
    <div id="filterPanels"></div>
</div>

    <link rel="stylesheet" href="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/adhoc/api/css/adHocView.css" type="text/css" media="screen">

<script>
    require = {
        baseUrl: "http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts"
    }
</script>
        <script type="text/javascript" src="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/lib/require-jquery-2.1.2.js"></script>
<script type="text/javascript" src="http://build-master.jaspersoft.com:7680/jrs-pro-feature-amber-adv/scripts/adHocView.require.config.js"></script>

CSS

#typeChooser {
    width: 250px;
}
#dataSelector {
    width: 250px;
}

.slider {
    width: 200px;
}

body {
    font-size: 11px;
    line-height: 1.182em;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-weight: normal;
}

.tooltip {
    position: absolute;
    padding: 4px;
    text-align: center;
    background: #eee;
    border: solid 1px #ccc;
    z-index: 1000;
    display: none;
    white-space: nowrap;
}

.sliderTick {
    position: absolute;
    background: url(http://gavmacbook.local:8080/jasperserver-pro-adv/themes/default/images/slider_tickMark.png);
    width: 3px;
    height: 23px;
    top: -4px;
    z-index: 0;
    margin-left: -1px;
}

.sliderContainer {
    padding-top: 15px;
}

.tickOverlay {
    position: absolute;
    height: 23px;
    width: 20px;
    left: -10px;
}

/*! perfect-scrollbar - v0.4.6
* http://noraesae.github.com/perfect-scrollbar/
* Copyright (c) 2013 HyeonJe Jun; Licensed MIT */

.ps-container .ps-scrollbar-x-rail{position:absolute;bottom:3px;height:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0.7;filter:alpha(opacity=70);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color.2s linear,opacity .2s linear;-moz-transition:background-color .2s linear,opacity .2s linear;transition:background-color .2s linear,opacity .2s linear}.ps-container:hover .ps-scrollbar-x-rail,.ps-container.hover .ps-scrollbar-x-rail{opacity:.6;filter:alpha(opacity=60)}.ps-container .ps-scrollbar-x-rail:hover,.ps-container .ps-scrollbar-x-rail.hover{/*background-color:#eee;*/opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-x-rail.in-scrolling{opacity:.9;filter:alpha(opacity=90)}.ps-container .ps-scrollbar-y-rail{position:absolute;right:3px;width:8px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;opacity:0.7;filter:alpha(opacity=70);-o-transition:background-color .2s linear,opacity .2s linear;-webkit-transition:background-color.2s...

JavaScript

require(["jquery", "adhoc/api/AdHocViewFacade", "common/transport/xdmRequest"], function($, AdHocView, request) {
    "use strict";

    request.configure({urlContext: "http://build-master.jaspersoft.com:5780/jrs-pro-feature-amber-adhoc-rest-api"});

    var adHocView = new AdHocView({
        container: "#dataView",
        layout: {
            chart: {
                typeChooser: "#typeChooser",
                dataLevelSelector: "#dataSelector",
                properties: false
            }
        }
    });
    
    adHocView.run("/public/Samples/Ad_Hoc_Views/8__Key_Performance_Metric_Trend").then(function() {
//    adHocView.components.chart.changeDataLevel(0, "Total");
//    adHocView.components.chart.render();

        adHocView.components.filterPanel.setComplexExpression("A");
        adHocView.components.filterPanel.view.render();
        
        adHocView.components.ichart.setProperty("xAxisRotation", 90).renderAll();
    });    
});