Eri*_*icA 5 r d3.js rcharts sankey-diagram htmlwidgets
我真的很喜欢桑基图的粒子可视化
https://bl.ocks.org/micahstubbs/6a366e759f029599678e293521d7e26c
但是,我无法在 R 中复制相同的内容,因为我对嵌入脚本一无所知。下面是用于创建 sankey 闪亮应用程序的代码 关于我如何实现它的任何帮助/指针都会有所帮助。
#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)
})
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
323 次 |
| 最近记录: |