- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我在 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 = 100))
g$xAxis(axisLabel = "x",
tickFormat = "#!function(x) {return d3.format(',.0f')(x);}!#")
g$yAxis(axisLabel = "y",
width = 100,
tickFormat = "#!function(y) {return d3.format(',.0f')(y);}!#",
showMaxMin = FALSE)
g
最佳答案
我刚刚在查看标记为 R
的未回答问题时发现了这一点。对不起,我错过了。 rCharts
已停滞,但正在寻找基于更灵活的 htmlwidgets
基础架构的新版本。我确信这个答案已经太晚了,但我已经更改了模板以允许对 y2Axis
进行格式化。
# uncomment this to install the fix
#devtools::install_github("timelyportfolio/rCharts")
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 <- "c:/users/kent.tleavell_nt/dropbox/development/r/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",
tickFormat = "#!function(x) {return d3.format(',.0f')(x);}!#")
g$yAxis(axisLabel = "y",
width = 100,
tickFormat = "#!function(y) {return d3.format(',.0f')(y);}!#",
showMaxMin = FALSE)
g$x2Axis(tickFormat = "#!function(x) {return d3.format('1.2s')(x);}!#")
# now we have a new y2Axis function
g$y2Axis(
tickFormat = "#!function(y) {return d3.format('1.2s')(y);}!#"
)
g
关于javascript - rCharts nvd3 lineWithFocusChart 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31479745/
我在 rCharts 上使用 nvd3,想知道是否有办法在 lineWithFocusChart 上自定义下部取景器图表的轴。我在下面提供了一个可重现的示例,我在其中自定义 x 轴和 y 轴以用逗号分
我的 LineWithFocusChart 有问题。每当我使用 interpolate('cardinal') 时,图形线就会在图形的边界处被切断。如何添加某种填充或使图形能够在其边框之外绘制? 最佳
我正在 nvd3 中使用 View Finder 创建折线图,我的问题是即使在(未排序的)数组和 .tickValues 的帮助下指定我的刻度,结果也会再次排序。更清楚一点:我的数组包含类似 (49,
我正在使用 nv.models.lineWithFocusChart ,我在这里展示了一些每小时的测量值。所以 x 域是日期。 我需要的是在 X 轴上每小时显示一个刻度: 00:00 01:00 02
我是一名优秀的程序员,十分优秀!