Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. output$Test1 <- renderUI({
  2. list(
  3. tags$head(tags$script(HTML('Shiny.addCustomMessageHandler("jsCode", function(message) { eval(message.value); });'))),
  4. tableOutput("table3")
  5. )
  6. })
  7.  
  8. tabPanel(
  9. div("Standings", style ='color: darkgrey'),
  10. selectInput("Year", h4("Year", style="color: silver"), c('All Time','2016','2017'), selected = 'All'),
  11. tableOutput('table1'),
  12. list(tags$table(tags$style("#table1 {color: white;}"))),
  13. tableOutput('table2'),
  14. list(tags$table(tags$style("#table2 {color: white;}"))),
  15. uiOutput("Test1")
  16. ),
  17.  
  18. `script <- "
  19. // Set min and max for gradient
  20. var min = 0;
  21. var max = 100;
  22. var n = max-min
  23.  
  24.  
  25. // Define the min colour, which is white
  26. xr = 205; // Red value
  27. xg = 173; // Green value
  28. xb = 0; // white value
  29.  
  30. // Define the max colour #2ca25f
  31. yr = 44; // Red value
  32. yg = 162; // Green value
  33. yb = 95; // white value
  34.  
  35.  
  36. $('tbody tr td:nth-child(n+2)').each(function() {
  37. var val = parseInt($(this).text());
  38.  
  39. // Catch exceptions outside of range
  40. if (val > max) {
  41. var val = max;
  42. }
  43.  
  44. else if (val < min) {
  45. var val = min;
  46. }
  47.  
  48. // Find value's position relative to range
  49.  
  50. var pos = ((val-min) / (n-1));
  51.  
  52. // Generate RGB code
  53. red = parseInt((xr + (( pos * (yr - xr)))).toFixed(0));
  54. green = parseInt((xg + (( pos * (yg - xg)))).toFixed(0));
  55. white = parseInt((xb + (( pos * (yb - xb)))).toFixed(0));
  56.  
  57. clr = 'rgb('+red+','+green+','+white+')';
  58.  
  59. // Apply to cell
  60.  
  61. $(this).css('background-color', clr);
  62.  
  63. })"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement