hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 37 forks source link

Trelliscopejs external images not rendering in Shiny #87

Open CosmoM opened 4 years ago

CosmoM commented 4 years ago

Hi Hafen I am running Trelliscope in R, displaying images and related data as labels. However, when I try to put everything into Shiny, the browser renders a blank page. I have narrowed the issue down to rendering external images. Is there a way to do this in Shiny?

output$trello <- renderTrelliscope({ return(new_table %>% select(url1, Product_ID, Product, .....

url1 is a vector of image urls:

) %>% mutate( panel = img_panel(url1), ....

Please assist

hafen commented 4 years ago

There were a lot of issues with using trelliscopejs in Shiny until recent updates. What version are you using?

CosmoM commented 4 years ago

Hi Hafen,thanks for the package and thanks for responding, R Version 3.6.2 trelliscopejs version 0.2.4

Kind Regards

hafen commented 4 years ago

Thanks. Actually if you could also send a minimal reproducible example, that would help me pinpoint the issue.

CosmoM commented 4 years ago

Hi Hafen I am new to R. I'll share my actual code, I've just changed the image urls to refer to amazon images. I ran the code outside Shiny and it works perfectly.

`library(shiny) library(shinydashboard) library(trelliscopejs) library(dplyr) library(readxl) library(mclust)

product_data <- read_excel('Amazon WK07.xlsx')

ui <- fluidPage( trelliscopeOutput("trello", width = "100%", height = "400px") )

server <- function(input, output) {

new_table <- product_data%>% mutate(url1= path) new_table

output$trello <- renderTrelliscope({ return(new_table %>% select(url1, Department, Third_Party_PL, Category_Level_1, Category_Level_2, Supplier, Brand, Seasonality, Supplier_Product_ID, Product_ID, Product, Current_Cost, Unit_RSP, Actual_Intake_Margin, MD_Tag, Revenue, Sales_Units_TW, Act_Sls_Mgn, Current_SKU_Availability, Current_Weeks_ATB, First_Sold_Date, Actual_Intake_Units, First_4_Weeks_Sales_Units, QTD_Sales_Units, SOH_Units, On_Order, Sellthru_This_Week, Sellthru_Last_Week, Link, Perf_Indicator) %>% mutate( panel = trelliscopejs::img_panel(url1), D_Weeks_ATB = round(as.numeric(Current_Weeks_ATB)), D_Product_ID = as.character(Product_ID), D_Current_Cost = round(as.numeric(Current_Cost), digits = 2), D_Revenue = round(as.numeric(Revenue), digits = 0), Actual_Intake_Margin = sprintf("%.1f%%", 100(as.numeric(Actual_Intake_Margin))), D_Act_Sls_Mgn = sprintf("%.1f%%", 100(as.numeric(Act_Sls_Mgn))), D_Unit_RSP = currency(Unit_RSP, symbol = "R", sep = "", big.mark = " "), D_Current_Cost = currency(Current_Cost, symbol = "R", digits = 2L, big.mark = " "), D_SKU_Avail = sprintf("%.1f%%", 100(as.numeric(Current_SKU_Availability, digits = 0))), D_Sellthru_This_Week = sprintf("%.1f%%", 100(Sellthru_This_Week)), D_Sellthru_Last_Week = sprintf("%.1f%%", 100*(as.numeric(Sellthru_Last_Week))) )%>% trelliscope(name = "Product Images", nrow=1, ncol=5, self_contained = T) )

})

}

shinyApp(ui, server)`

Amazon WK07.xlsx