我已经创建了一个简单的闪亮应用程序,我想从Java动态Web项目运行该应用程序。为此,我在index.html中包含了所需的代码。我能够获得No Bins滑块,但无法获得绘图。是否可以直接在浏览器中从动态Web项目运行闪亮的应用程序?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="application/shiny-singletons"></script>
<script type="application/html-dependencies">json2[2014.02.04];jquery[1.12.4];shiny[1.2.0];ionrangeslider[2.1.6];strftime[0.9.2];bootstrap[3.3.7]</script>
<script src="shared/json2-min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20150503/json2.min.js"></script> -->
<script src="shared/jquery-1.12.4.min.js"></script>
<link href="shared/shiny.css" rel="stylesheet" />
<script src="shared/shiny.min.js"></script>
<link href="shared/ionrangeslider/css/ion.rangeSlider.css" rel="stylesheet" />
<link href="shared/ionrangeslider/css/ion.rangeSlider.skinShiny.css" rel="stylesheet" />
<script src="shared/ionrangeslider/js/ion.rangeSlider.min.js"></script>
<script src="shared/strftime/strftime-min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="shared/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script src="shared/bootstrap/js/bootstrap.min.js"></script>
<script src="shared/bootstrap/shim/html5shiv.min.js"></script>
<script src="shared/bootstrap/shim/respond.min.js"></script> <title>Old Faithful Geyser Data</title>
</head>
<body>
<div class="container-fluid">
<h2>Old Faithful Geyser Data</h2>
<div class="row">
<div class="col-sm-4">
<form class="well">
<div class="form-group shiny-input-container">
<label class="control-label" for="bins">Number of bins:</label>
<input class="js-range-slider" id="bins" data-min="1" data-max="50" data-from="30" data-step="1" data-grid="true" data-grid-num="9.8" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-data-type="number"/>
</div>
</form>
</div>
<div class="col-sm-8">
<div id="distPlot" class="shiny-plot-output" style="width: 100% ; height: 400px"></div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
一个闪亮的应用程序不仅仅是原始HTML。如果您使用闪亮应用程序的html并将其另存为文件,然后尝试在s浏览器中打开该文件,它将呈现,但不会起作用/无法交互。这是因为Shiny需要后端服务器(一个R进程)来为其供电,并将输出发送到页面。如果没有R进程运行闪亮的服务器,那么它只是一个静态HTML页面。您可以在线(在Shinyapps.io上或在闪亮的服务器上)托管应用,并在Java应用中使用指向该闪亮应用的iframe。