I really like the Particle visualization of Sankey diagram
https://bl.ocks.org/micahstubbs/6a366e759f029599678e293521d7e26c
However, i cant replicate the same in R shiny as i have no knowledge on embedding scripts . Below is code for creating a sankey shiny app Any help /pointers as to how can i achieve it would be helpful .
#ui
library(shiny)
library(rCharts)
shinyUI(bootstrapPage(
div(
class="container-fluid",
div(class="row-fluid",
headerPanel("Path Explorer")
),
div(class="row-fluid",
sidebarPanel(
h4("Sankey Visualisation")
),
mainPanel(
tableOutput("table"),
showOutput('sankey' ,'C:/Users/neha.sharma/Desktop/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey') # I refer to this directory later on in this message
)
)
)
))
#server
library(shiny)
library(rCharts)
shinyServer(function(input, output){
data <- reactive({
data <- data.frame(
source = c("peugot","Tagesschau.de","BMW.DE","DirectExit","Amazon.de","Google.com","BMW.DE","BMWgroup.com","facebook","directaccess","BMW.DE","Peugot","bing1","bing","BMW.DE","Mobile.DE"),
target = c("Tagesschau.de", "BMW.DE","DirectExit","DirectExit2","Google.com","BMW.DE","BMWgroup.com","BMWAuto","directaccess", "BMW.DE" ,"Peugot", "Peugot(2)","bing","BMW.DE","Mobile.DE","Mobile_Last"),
value=c("8","6.3","5.5","5.4","5.4","23.5","11","5.4","3","5","4.5","8","6.3","5.5","5.4","5.4"))
#return(data)
})
#output$table <- renderTable({
# return(data())
#})
output$sankey <- renderChart2({
sankeyPlot <- rCharts$new()
sankeyPlot$setLib("C:/Users/neha.sharma/Desktop/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey")
#C:/Users/neha.sharma/Desktop/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey
sankeyPlot$set(
data = data(),
nodeWidth = 15,
nodePadding = 10,
layout = 40,#32
labelFormat = ".1%",
width = 800,
height = 600
)
return(sankeyPlot)
})
})