Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browsable, renderUI or Sunburst? #34

Closed
tyjselina opened this issue Apr 5, 2017 · 11 comments
Closed

Browsable, renderUI or Sunburst? #34

tyjselina opened this issue Apr 5, 2017 · 11 comments

Comments

@tyjselina
Copy link

@tyjselina tyjselina commented Apr 5, 2017

Based on this http://timelyportfolio.github.io/sunburstR/example_baseball.html example (use sunburst event), I want to wrapped it into an interactive shiny app (the click on within an interactive shiny app). What I did previously is put the (browsable function/tagList) into the renderUI function,

`output$sunburst = renderUI({tagList(
sb,
tags$div(id="games", style="margin-top:100px"),
tags$script(HTML(
sprintf(
'
var action = %s;

function mouseovered(d){
var games = action.filter(function(evt){
return evt.event === d.join("-");
});

var div = document.getElementById("games");
div.innerHTML = games.map(function(game){
return [
"<a href='http://gd2.mlb.com/components/game/mlb/year_2016/month_08/day_25/",
game.gameday_link,
"'>",
game.gameday_link,
"
"
].join("");
}).join("\n");
}
',
jsonlite::toJSON(action, auto_unbox=TRUE, dataframe="row")
)
))
)})`

It works fine. But after I updated the sunburst package from 0.6.2 to 0.6.3, the generated sunburst chart is not shown up in the app. So I am wondering which parts has change resulting in the in-compatible of browsable/sunburst with renderUI

My current shiny version is shiny_0.14, R and R studio version is 3.3.2 and 0.99.902

Many thanks

@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 5, 2017

Changes in 0.6.3

In 0.6.3, sunburst changed to use d3r for the d3 dependency, but this did not seem to affect any shiny examples that I tried. Can you try?

library(shiny)
library(sunburstR)
library(htmltools)


# read in sample visit-sequences.csv data provided in source
#   https://gist.github.com/kerryrodden/7090426#file-visit-sequences-csv
sequences <- read.csv(
  system.file("examples/visit-sequences.csv",package="sunburstR")
  ,header = FALSE
  ,stringsAsFactors = FALSE
)

sb <- sunburst(sequences)

ui <- htmlOutput("sb")

server <- function(input, output, session) {
  output$sb <- renderUI(tagList(sb))
}

shinyApp(ui, server)

Errors in JavaScript console

Would you be able to open your broken example in Chrome/Firefox/Safari to inspect the JavaScript console for errors? Usually, F12 or CTRL + Shift + J will open the debugger window.

Better Way?

I thought I would add some thoughts on a better way to approach your objective, by using the add_shiny() function and rendering your UI/HTMLoutput separately from the sunburst chart. See shiny example for an illustration. Happy to help work through this if you like the idea.

@tyjselina
Copy link
Author

@tyjselina tyjselina commented Apr 10, 2017

Hello, the code doesn't work on my machine. Just want to confirm with you the shiny version of your machine?

@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 10, 2017

@tyjselina,

shiny       * 1.0.1   2017-04-01 CRAN (R 3.3.3)  

but I think the issue might be htmltools. Will you update to the github version of that and see if there is any effect?

devtools::install_github("rstudio/htmltools")
@tyjselina
Copy link
Author

@tyjselina tyjselina commented Apr 12, 2017

Many thanks. That works perfect!

@tyjselina
Copy link
Author

@tyjselina tyjselina commented Apr 12, 2017

Just noticed one more thing, for the sunburst version of 0.6.4, it seems the legendOrder statement doesn't work on my computer, as if I click the checkbox, there is no text. For example(in the middle part),
#17 (comment)

Let me know if I need to do more update.

Thank you for your great work.

@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 12, 2017

Darn I thought I tested but could have easily messed it up with new color functionality. I will check by next week and fix.

timelyportfolio added a commit that referenced this issue Apr 13, 2017
@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 13, 2017

@tyjselina, thanks again for the report. I believe I have fixed the issue. Please let me know if it does not work as expected for you.

@tyjselina
Copy link
Author

@tyjselina tyjselina commented Apr 13, 2017

@timelyportfolio It stays the same for me, there is still no text. Any ideas?

@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 13, 2017

Did you do a fresh install_github? Are you copy/pasting that example? If not could you post code?

@tyjselina
Copy link
Author

@tyjselina tyjselina commented Apr 16, 2017

Thank you! It works! Previously I reinstalled the package from the cran, so I think that's the reason why it doesn't work.

@timelyportfolio
Copy link
Owner

@timelyportfolio timelyportfolio commented Apr 16, 2017

Great to hear. I will try to push to CRAN by end of week. Thanks again for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.