小编dig*_*ter的帖子

使用鼠标点击进行交互式绘图

我正在做一个项目,我使用闪亮的服务器并将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)

r shiny

4
推荐指数
1
解决办法
6117
查看次数

为什么这个EventSource会反复触发消息和错误?

客户端看起来像这样:

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)

javascript node.js eventsource

4
推荐指数
1
解决办法
7342
查看次数

获取与js对象中的值对应的键

我有一个对象,例如:

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但没有成功.

javascript arrays node.js

3
推荐指数
1
解决办法
9123
查看次数

在React中嵌套组件,不传递给子组件的props

我正在创建一个包含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)

最多子组件的控制台日志不显示任何道具

javascript components reactjs

1
推荐指数
1
解决办法
2380
查看次数

标签 统计

javascript ×3

node.js ×2

arrays ×1

components ×1

eventsource ×1

r ×1

reactjs ×1

shiny ×1