From 3a7c90eab6581f591f817e7f06e6633aae00f749 Mon Sep 17 00:00:00 2001 From: "Carlos R. Mercado" <107061601+charlieflipside@users.noreply.github.com> Date: Mon, 15 Aug 2022 10:54:48 -0400 Subject: [PATCH] Switch to Reactable table Still have todo list --- .gitignore | 3 ++- eoa/global.R | 20 ++++------------ eoa/server.R | 4 +++- eoa/ui.R | 9 ++++---- eoa/www/styles.css | 9 ++++---- renv.lock | 57 +++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 73 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 8931028..aee176a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,5 @@ po/*~ rsconnect/ # ShroomDK api key -api_key.txt \ No newline at end of file +api_key.txt +task.txt diff --git a/eoa/global.R b/eoa/global.R index d84ce13..5eb7c59 100644 --- a/eoa/global.R +++ b/eoa/global.R @@ -1,3 +1,4 @@ +library(shinyjs) library(jsonlite) library(httr) library(shroomDK) @@ -5,6 +6,7 @@ library(ggplot2) library(plotly) library(dplyr) library(DT) +library(reactable) # gitignored - get your own ShroomDK key from Flipside Crypto! api_key <- readLines("api_key.txt") @@ -93,8 +95,8 @@ tbl_eoa <- function(eoadh = eoa_daily_history, eoa_activity){ x = data.frame( "Days Active" = eoa_activity$DAYS_ACTIVE, - "Number of Tx" = eoa_activity$NUM_TX, - "Active Days Percentile" = { + "Tx Count" = eoa_activity$NUM_TX, + "Percentile" = { paste0( 100 * round( @@ -106,19 +108,7 @@ tbl_eoa <- function(eoadh = eoa_daily_history, eoa_activity){ ) - datatable(x, - options = list(paging = FALSE, ## paginate the output - searching = FALSE, - autoWidth = TRUE, ## use smart column width handling - server = FALSE, ## use client-side processing - dom = 't', - columnDefs = list(list(targets = '_all', - className = 'dt-center')) - ), - extensions = 'Buttons', - filter = 'none', - rownames = FALSE - ) + return(x) } diff --git a/eoa/server.R b/eoa/server.R index e329e3f..a3d027c 100644 --- a/eoa/server.R +++ b/eoa/server.R @@ -15,8 +15,10 @@ shinyServer(function(input, output) { }) - output$compare <- DT::renderDataTable({ + output$compare <- renderReactable({ + reactable( tbl_eoa(eoa_daily_history, eoa_activity = results()) + ) }) output$main_plot <- renderPlotly({ diff --git a/eoa/ui.R b/eoa/ui.R index 060b863..9486174 100644 --- a/eoa/ui.R +++ b/eoa/ui.R @@ -1,5 +1,4 @@ library(shiny) -library(shinyjs) source("global.R") # Define UI ------- @@ -55,20 +54,20 @@ shinyUI(fluidPage( div( # re-using chart classes to make smoother outlining class = 'chart-container', div( - class = 'chart-block', + class = 'chart-block eoa-bar', fluidRow( - column(10, class = 'eoa-bar', + column(10, textInput(inputId = "address", label = "", placeholder = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", width = '100%') ), - column(2, class = 'eoa-btn', + column(2, class = 'eoa-btn', actionButton("submit", label = "Search") ) ), conditionalPanel("input.submit > 0", div(class = 'eoa-tbl', - dataTableOutput("compare") + reactableOutput("compare") ) ) )), diff --git a/eoa/www/styles.css b/eoa/www/styles.css index ca889c8..67c6d2f 100644 --- a/eoa/www/styles.css +++ b/eoa/www/styles.css @@ -3,11 +3,11 @@ /*PUT CUSTOM CLASSES HERE*/ /*******************/ -.eoa-bar { - text-align: center; - margin: 0% 5%; +.eoa-bar { + text-align: center; } -.eoa-btn { + +.eoa-btn { margin-top: 30px; } @@ -152,6 +152,7 @@ hr { background: #10151A; border: 1px solid #03FFFF; border-radius: 4px; + margin-left: 30px; font-family: Roboto Mono !important; color: #FFFFFF; } diff --git a/renv.lock b/renv.lock index 0bb8a5e..b0a7e2f 100644 --- a/renv.lock +++ b/renv.lock @@ -33,6 +33,16 @@ "Hash": "4bf2c61e656bbc238634c798c208d386", "Requirements": [] }, + "Matrix": { + "Package": "Matrix", + "Version": "1.4-1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "699c47c606293bdfbc9fd78a93c9c8fe", + "Requirements": [ + "lattice" + ] + }, "R6": { "Package": "R6", "Version": "2.5.1", @@ -273,6 +283,7 @@ "glue", "gtable", "isoband", + "mgcv", "rlang", "scales", "tibble", @@ -392,6 +403,14 @@ "rlang" ] }, + "lattice": { + "Package": "lattice", + "Version": "0.20-45", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b64cdbb2b340437c4ee047a1f4c4377b", + "Requirements": [] + }, "lazyeval": { "Package": "lazyeval", "Version": "0.2.2", @@ -430,6 +449,17 @@ "rlang" ] }, + "mgcv": { + "Package": "mgcv", + "Version": "1.8-40", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c6b2fdb18cf68ab613bd564363e1ba0d", + "Requirements": [ + "Matrix", + "nlme" + ] + }, "mime": { "Package": "mime", "Version": "0.12", @@ -454,7 +484,9 @@ "Source": "Repository", "Repository": "CRAN", "Hash": "9469aeaeddf4f48a7ac70877d0b7ba36", - "Requirements": [] + "Requirements": [ + "lattice" + ] }, "openssl": { "Package": "openssl", @@ -629,11 +661,30 @@ "xtable" ] }, + "shinyjs": { + "Package": "shinyjs", + "Version": "2.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "802e4786b353a4bb27116957558548d5", + "Requirements": [ + "digest", + "jsonlite", + "shiny" + ] + }, "shroomDK": { "Package": "shroomDK", "Version": "0.1.0", - "Source": "unknown", - "Hash": "3ff435b21b1512b7ad7f271c5e787471", + "Source": "GitHub", + "RemoteType": "github", + "RemoteHost": "api.github.com", + "RemoteRepo": "sdk", + "RemoteUsername": "FlipsideCrypto", + "RemoteRef": "HEAD", + "RemoteSha": "c5dd70f702d57374f294d7107109ca1819dca863", + "RemoteSubdir": "r/shroomDK", + "Hash": "020a689f6cd0bb4d8e0d7411c7fbe3ab", "Requirements": [ "httr", "jsonlite"