小编joh*_*838的帖子

rCharts nvd3 lineWithFocusChart Customization

我在rCharts上使用nvd3,并且想知道是否有一种方法可以在lineWithFocusChart上自定义下部取景器图形的轴.我在下面提供了一个可重现的示例,其中我自定义x和y轴以使逗号分隔数千个位置,但该格式不显示在下部取景器图表上.怎么能解决这个问题?谢谢!

      library(rCharts)
      temp <- data.frame(x = 1:2000, y = 1:2000, z = c(rep(1,1000), rep(0,1000)))
      g <- nPlot(y ~ x, group = "z", data = temp, type = "lineWithFocusChart")
      g$templates$script <- "http://timelyportfolio.github.io/rCharts_nvd3_templates/chartWithTitle_styled.html"
      g$set(title = "Example")  
      g$chart(transitionDuration = -1,
              tooltipContent = "#! function(key, x, y) {
                                return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
                              }!#", 
              showLegend = FALSE, margin = list(left = 200, 
                                                right = 100, 
                                                bottom = 100,
                                                top = …
Run Code Online (Sandbox Code Playgroud)

javascript r nvd3.js rcharts

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

Rcharts nvd3 2-D zoom可能吗?

在nvd3中是否有缩放功能,我可以直接输入我的R源代码(如果只要我不需要更改nvd3源代码就需要javascript无关紧要)?我尝试了lineWithFocusChart,但只是沿着x轴放大,而我想理想的是在缩放部分周围画一个框,它会缩放到我绘制框的位置.即使这是不可能的,如果nvd3支持任何类型的2-d变焦,那将是非常棒的!我提供了一个可重现的例子,我到目前为止,但我还没有找到我正在寻找的缩放功能.谢谢!

      library(rCharts)
      temp <- data.frame(x = 1:100, y = 1:100, z = c(rep(1,50), rep(0,50)))
      g <- nPlot(y ~ x, group = "z", data = temp, type = "lineChart")
      g$templates$script <- "http://timelyportfolio.github.io/rCharts_nvd3_templates/chartWithTitle_styled.html"
      g$set(title = "Example")  
      g$chart(transitionDuration = -1,
              tooltipContent = "#! function(key, x, y) {
                                    return 'z: ' + key + '<br/>' + 'x: ' + x + '<br/>' + 'y: ' + y 
                                  }!#", 
              showLegend = FALSE, margin = list(left = 200, 
                                                right = 100, 
                                                bottom = 100,
                                                top = …
Run Code Online (Sandbox Code Playgroud)

javascript r zoom nvd3.js rcharts

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

正则表达式在最后一个单词之前查找空格

我想在字符串的最后一个字之前找到空格.

例如,对于

Bob Jane
Run Code Online (Sandbox Code Playgroud)

我想在Jane之前找到空间.我正在尝试查找并替换所有以使其成为逗号.因此,最终结果将是

Bob ,Jane
Run Code Online (Sandbox Code Playgroud)

我只是在文本编辑器中使用(使用Sublime),所以我没有使用编程语言.谢谢!

regex sublimetext2

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

闪亮的改变滑块动画速度

我想知道是否有办法改变闪亮滑块的动画速度.因此,对于(在ui.R中)的滑块:

sliderInput("test_slider", 
            "Animation:", 
             min = 1, 
             max = 200, 
             value = 100, 
             animate = animationOptions(interval = ANIMATION SPEED))
Run Code Online (Sandbox Code Playgroud)

我希望能够更改ANIMATION SPEED,而不是将其保持在我在开头设置的静态值.此外,动画仅在我将其放入ui时才有效,因此我无法将其作为服务器中的反应UI.例如,我不能在server.R中做

output$test_slider <- renderUI({
   sliderInput("test_slider", 
               "Animation:", 
                min = 1, 
                max = 200, 
                value = 100, 
                animate = animationOptions(interval = ANIMATION SPEED))
})
Run Code Online (Sandbox Code Playgroud)

然后添加ui.R

uiOutput("test_slider")
Run Code Online (Sandbox Code Playgroud)

这本来是理想的,因为我自定义了诸如min和max之类的东西(可能还有ANIMATION SPEED),但遗憾的是这样做会使播放按钮无效并且动画无法启动.我对如何动态更改滑块输入参数感到茫然.即使你的解决方案涉及javascript,我也会完全没问题.非常感谢.


编辑:

所以我还没有答案,但我已经接近了.我查看了javascript文件并添加了类似的内容(在ui.R中):

         numericInput("anim",
                      "interval: ",
                      value = 100),
         sliderInput("test_slider",
                    "Animation",
                     min = 1,
                     max = 200,
                     value = 100,
                     step = 1,
                     animate = animationOptions(interval = 700,
                               playButton = icon('play', "fa-3x"), …
Run Code Online (Sandbox Code Playgroud)

animation r dynamic slider shiny

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

如何在Shiny Application的onStart参数中设置全局变量值

我正在尝试使用R包Shiny中的函数ShinyApp的onStart参数来设置全局变量,而不是使用global.R文件。因此,格式为

shinyApp(onStart = ..., ui = ..., server = ...)
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法设置全局变量。例如,如果我执行以下操作:

shinyApp(
    onStart = function() { 
          temp1 <- 2
          temp2 <- 3
          temp3 <- 4
    },
    ui = fluidPage(
         titlePanel("test"),
         mainPanel(uiOutput("test_slider"))),
    server = function(input, output, session) {
         output$test_slider <- renderUI({
         sliderInput("test_slider",
                     "Testing",
                     min = 0,
                     max = temp1 + temp2 + temp3 + temp4,
                     value = 0

         )
      })
    }
)
Run Code Online (Sandbox Code Playgroud)

执行此操作时,出现错误“找不到对象temp1”。我不太确定如何进行这项工作,因此将不胜感激任何建议或解决方案!

graphics r global-variables shiny

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