Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- output$Test1 <- renderUI({
- list(
- tags$head(tags$script(HTML('Shiny.addCustomMessageHandler("jsCode", function(message) { eval(message.value); });'))),
- tableOutput("table3")
- )
- })
- tabPanel(
- div("Standings", style ='color: darkgrey'),
- selectInput("Year", h4("Year", style="color: silver"), c('All Time','2016','2017'), selected = 'All'),
- tableOutput('table1'),
- list(tags$table(tags$style("#table1 {color: white;}"))),
- tableOutput('table2'),
- list(tags$table(tags$style("#table2 {color: white;}"))),
- uiOutput("Test1")
- ),
- `script <- "
- // Set min and max for gradient
- var min = 0;
- var max = 100;
- var n = max-min
- // Define the min colour, which is white
- xr = 205; // Red value
- xg = 173; // Green value
- xb = 0; // white value
- // Define the max colour #2ca25f
- yr = 44; // Red value
- yg = 162; // Green value
- yb = 95; // white value
- $('tbody tr td:nth-child(n+2)').each(function() {
- var val = parseInt($(this).text());
- // Catch exceptions outside of range
- if (val > max) {
- var val = max;
- }
- else if (val < min) {
- var val = min;
- }
- // Find value's position relative to range
- var pos = ((val-min) / (n-1));
- // Generate RGB code
- red = parseInt((xr + (( pos * (yr - xr)))).toFixed(0));
- green = parseInt((xg + (( pos * (yg - xg)))).toFixed(0));
- white = parseInt((xb + (( pos * (yb - xb)))).toFixed(0));
- clr = 'rgb('+red+','+green+','+white+')';
- // Apply to cell
- $(this).css('background-color', clr);
- })"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement