JSFiddle - React, Tailwind, and code Playground

by Pavel Savushchyk

HTML

<script src="http://localhost:8080/trunk/client/visualize.js?_opt=true"></script>

<div>
  IC Value
  <input id="text" type="text" value="30">
  <button id="apply">Apply</button>
</div>

<div>
  Count of values received:
  <span id="res"></span>
</div>
<!--Provide container to render your visualization-->
<div id="container" style="height: 400px;position: relative"></div>

JavaScript

visualize({
  auth: {
    name: "jasperadmin",
    password: "jasperadmin",
    organization: "organization_1"
  }
}, function(v) {
  var adv,
    text = document.getElementById("text"),
    apply = document.getElementById("apply"),
    res = document.getElementById("res");

  adv = v.adhocView({
    resource: "/public/Samples/Ad_Hoc_Views/01__Geographic_Results_by_Segment",
    container: "#container",
    success: function() {
      console.log(arguments);
    },
    error: function() {
      alert("error");
      console.log(arguments);
    }
  });

  apply.onclick = function() {
    adv.params({
      sales_fact_ALL__store_sales_2013_1: [parseInt(text.value)]
    }).run().done(function(data) {
      res.innerHTML = "[" + data._dataset_internal_.counts.join() + "]";
    }).fail(function() {
      console.log("fail");
      console.log(arguments);
    })
  }
});