Rcharts nvd3是否支持2D缩放?

9
nvd3中是否有缩放功能,能否直接在我的R源代码中输入(只要不需要更改nvd3源代码就可以使用javascript)?我尝试了lineWithFocusChart,但那只能沿着x轴缩放,我想最好是绘制一个框,将缩放部分的内容缩放到我所绘制的位置。即使不可能实现这一点,如果nvd3支持任何类型的2D缩放,那也很棒!我提供了一个可重现的示例,但我还没有找到我正在寻找的缩放功能。谢谢!
      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
1个回答

1
您可以使用带有zoomType选项的Highcharts
例如:
require(rCharts)

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

你可以拖动和按住图表来缩放区域。

我以前使用过Highcharts,但不得不更换,因为它不允许商业使用。我发现的第二好选择是rCharts中的nvd3,所以我希望在nvd3中找到类似的缩放功能。 - johnny838

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接