我正在尝试将RChart嵌入到闪亮的应用程序中.我特意使用该nPlot函数来创建type=scatterChartNVD3样式图.在下面的NVD3网站示例中,我有兴趣在我的RCharts闪亮应用程序中工作的两个功能:
http://nvd3.org/ghpages/scatter.html
有谁知道如何扩展我的代码以实现这两个功能.闪亮的server.r和ui.r脚本包含在下面.
## server.r
library(rCharts)
library(shiny)
x <- rnorm(100)
y <- rnorm(100)
dat <- as.data.frame(cbind(x,y))
shinyServer(function(input, output) {
output$myChart <- renderChart({
p1 <- nPlot(y ~ x, data = dat, type = "scatterChart")
p1$addParams(dom = 'myChart')
p1$params$height=400
p1$params$width=650
return(p1)
})
})
## ui.R
library(rCharts)
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("rCharts: Interactive Charts from R using NVD3.js"),
sidebarPanel(
wellPanel(
helpText( "Look at the pretty graph"
)
),
wellPanel(
helpText( "Look at the pretty graph"
)
),
wellPanel(
helpText( "Look at the pretty graph"
)
)
),
mainPanel(
div(class='wrapper',
tags$style(".Nvd3{ height: 400px;}"),
showOutput("myChart","Nvd3")
)
)
))
Run Code Online (Sandbox Code Playgroud)
提前感谢您提供的任何建议.
这可以使用以下代码实现:
p1$chart(
showDistX = TRUE,
showDistY = TRUE
)
return(p1)
Run Code Online (Sandbox Code Playgroud)
此外,就像一张纸条,而直接操控p1$params的作品,它可能是更安全的规定height,并width以这种方式:
p1 <- nPlot(
y ~ x,
data = dat,
type = "scatterChart",
height = 400,
width = 650
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
518 次 |
| 最近记录: |