我正在做一个项目,我使用闪亮的服务器并将R连接到mongodb以从数据库中获取结果并动态显示它.
但是,我面临以下问题.我最初从db获得结果并制作一个情节.完成此绘图后,我希望用户在绘图上进行两次鼠标单击,根据该绘图将两个值作为xlim并绘制上一个绘图的缩放版本.但是,我无法成功完成.
这是我写的代码.
ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("LOAD AND PERFORMANCE DASHBOARD"),
sidebarLayout(
sidebarPanel(
fluidRow(
selectInput("select", label = h3("Select type of testing"),
choices = list("Performance Testing"=1, "Capacity Testing"=2)),
radioButtons("radio", label = h3("Select parameter to plot"),
choices = list("Disk" = 1, "Flit" = 2,"CPU" = 3,"Egress" =4,
"Memory" = 5))
)),
mainPanel(
plotOutput("plot",clickId="plot_click"),
textOutput("text1"),
plotOutput("plot2")
)
)
))
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
library(rmongodb)
cursor <- vector()
shinyServer(function(input, output) {
initialize <- reactive({
mongo = mongo.create(host = "localhost")
})
calculate <- reactive({
if(input$radio==1)
xvalue <- mongo.distinct(mongo,ns …Run Code Online (Sandbox Code Playgroud) 客户端看起来像这样:
var es = new EventSource("http://localhost:8080");
es.addEventListener("message", function(e) {
alert("e.data") //Alerts "" every couple seconds
})
es.addEventListener("error", function(e) {
alert("error") //Also fires every couple of seconds
})
var post_request = new XMLHttpRequest();
post_request.open("POST", "http://localhost:8080");
post_request.setRequestHeader("Content-Type", "text/plain");
post_request.addEventListener("readystatechange", function() {
if (post_request.readyState == 4 && post_request.status == 200) {
alert(post_request.responseText); //This works
}
})
post_request.send("This is a test")
Run Code Online (Sandbox Code Playgroud)
服务器端 Node.js 处理 POST 请求如下所示:
function process_request(request, response) {
var request_body = []
request.on("data", function(chunk) {
request_body.push(chunk)
})
request.on("end", function() {
request_body = …Run Code Online (Sandbox Code Playgroud) 我有一个对象,例如:
var inspectionMapping = {'a_pillar_lh' : "A Pillar LH",
'b_pillar_lh' : "B Pillar LH"};
console.log(inspectionMapping['a_pillar_lh']);
// Which gives me correct "A Pillar LH".
Run Code Online (Sandbox Code Playgroud)
我能够获得与key对应的值.
但是我无法获得与javascript对象中的值对应的键.
比如我"A Pillar LH"和我需要得到相应的密钥a_pillar_lh.
我试过用indexOf但没有成功.
我正在创建一个包含React组件的列表,并且正在处理列表容器和可重用的列表项组件.父组件将大部分组件传递给中间组件,但最多子组件没有props值.
我究竟做错了什么?没有控制台错误.
中间成分:
const VideoList = (props) => {
const videoItems = props.videos.map((video) => {
return (
// want to render list-item component
<li key={video.etag}>{video.snippet.title}</li>
)
});
return (
<ul className="list-group">
{videoItems}
<ListItem
videos={ videoItems }
/>
</ul>
)
}
Run Code Online (Sandbox Code Playgroud)
最多子组件的控制台日志不显示任何道具