I'm trying to embed an RChart into a shiny app. I'm specifically using the nPlot
function to create a type=scatterChart
NVD3 style plot. In the NVD3 website example below, there are two pieces of functionality I am interested in getting to work in my RCharts shiny app:
http://nvd3.org/ghpages/scatter.html
- It appears that a "rug" is included along the x-axis and y-axis of the above example, demonstrating marginally where the x and y points occur most frequently along their respective supports.
- Further, when one clicks on the chart and hovers over a specific point a vertical and horizontal line appear noting the (x,y) location of the corresponding point.
Does anyone know how to expand my code below to achieve these two pieces of functionality. Shiny server.r and ui.r scripts are included below.
## 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")
)
)
))
Thanks in advance for any advice you can provide.