Plotting Widget - basic example
HTML
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//cdn.opencpu.org/opencpu-0.4.js"></script>
<h1>UpSet Visualization</h1>
<button id="submitbutton" type="button">Send Data To Be Plotted</button> <br>
<div id="plotdiv"></div>
CSS
#plotdiv {
height: 400px;
border: solid gray 1px;
}
JavaScript
//set CORS to call "appdemo" package on public server
ocpu.seturl("http://ecd.pfizer.com/ocpu/library/UpSetR/R")
// Grab a JSON of Movies Data provided by the UpSetR Package
var url = 'https://raw.githubusercontent.com/josep2/testOPENCPU/master/test.json';
// Make an AJAX call to get the data
$.ajax({
type: 'GET',
url: url,
//async: false,
//contentType: "application/json",
dataType: 'json',
success: function (data) {
//call R and attach to the dive
$("button").click(function(){
var req = $("#plotdiv").rplot("upset", {
data : data
}).fail(function(){
alert("R returned an error: " + req.responseText);
});
});
},
error: function (e) {
console.log(e);
}
});