Skip to content

Commit

Permalink
change position:relative for htmlwidget div container so tooltip work
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Mar 5, 2016
1 parent 06998ed commit f235974
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 134 deletions.
44 changes: 44 additions & 0 deletions inst/examples/test_multiple_shiny.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# silly test to check multiple radviz on a page
# and make sure tooltips work as expected

library(shiny)
library(radviz)

ui <- fluidPage(
fluidRow(
column(
width = 6,
radvizOutput("radviz1")
),
column(
width = 6,
radvizOutput("radviz2")
)
)
)

server <- function(input,output,session){
output$radviz1 <- renderRadviz({
radviz(iris, diameter=400, margin=100,
use_repulsion=TRUE, draw_links=TRUE,
width=400, height=500
) %>%
add_dimensions(c('Sepal.Length', 'Sepal.Width',
'Petal.Length', 'Petal.Width')) %>%
add_color("Species") %>%
add_tooltip("function(d){ return 'Petal width: ' + d['Petal.Length']; }")
})

output$radviz2 <- renderRadviz({
radviz(iris, diameter=400, margin=100,
use_repulsion=TRUE, draw_links=TRUE,
width=400, height=500
) %>%
add_dimensions(c('Sepal.Length', 'Sepal.Width',
'Petal.Length', 'Petal.Width')) %>%
add_color("Species") %>%
add_tooltip("function(d){ return 'Petal width: ' + d['Petal.Length']; }")
})
}

shinyApp(ui,server)
23 changes: 12 additions & 11 deletions inst/examples/testmultiple_radviz.html

Large diffs are not rendered by default.

123 changes: 0 additions & 123 deletions inst/examples/testmultiple_radviz_broken.html

This file was deleted.

11 changes: 11 additions & 0 deletions inst/htmlwidgets/radviz.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ HTMLWidgets.widget({
return {

renderValue: function(x) {

/* fix multiple tooltip problem
for standalone we will need to explicitly
assign position : relative for our
htmlwidget container div
since radviz tooltip needs absolute positioning
I tested in tagList, rmarkdown, and shiny
*/
el.style.position = "relative";


var data = HTMLWidgets.dataframeToD3(x.data);

Expand Down

0 comments on commit f235974

Please sign in to comment.