gpt4 book ai didi

javascript - Rcharts nvd3 二维缩放可能吗?

转载 作者:数据小太阳 更新时间:2023-10-29 03:57:16 27 4
gpt4 key购买 nike

nvd3 中是否有缩放功能,我可以直接在我的 R 源代码中输入(只要我不必更改 nvd3 源代码,它是否需要 javascript 无关紧要)?我尝试了 lineWithFocusChart,但它只沿 x 轴缩放,而我想理想地在缩放部分周围绘制一个框,它会缩放到我绘制框的位置。即使那是不可能的,如果 nvd3 支持任何类型的二维缩放,那就太棒了!到目前为止,我已经提供了一个可重现的示例,但我还没有找到我正在寻找的缩放功能。谢谢!

      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

最佳答案

您可以将 HighchartszoomType 选项一起使用。

例如:

require(rCharts)

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

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

关于javascript - Rcharts nvd3 二维缩放可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31457930/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com