Rcharts nvd3 2-D zoom可能吗?

joh*_*838 9 javascript r zoom nvd3.js rcharts

在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 = 100))               
      g$xAxis(axisLabel = "x")
      g$yAxis(axisLabel = "y", width = 40)
      g
Run Code Online (Sandbox Code Playgroud)

Nic*_*icE 1

您可以使用HighchartszoomType选项。

例如:

require(rCharts)

names(iris) = gsub("\\.", "", names(iris))
g<-hPlot(SepalLength ~ SepalWidth, data = iris, color = 'Species', type = 'line')
g$chart(zoomType = 'xy')
g
Run Code Online (Sandbox Code Playgroud)

然后,您可以拖动并按住图来放大某个区域。