问题描述
在您的帮助下,我已经能够创建一个双圆环图。我现在要添加的是内部甜甜圈切片之间的一些线条。不幸的是,我不知道如何:)
我想要实现的是能够加载一个将旧 ID 链接到新 ID 的 csv,然后在 plot_ly() 中动态地看到它作为新层/跟踪呈现。
- IV.1 到 X.2
- IV.1 到 X.6
- IV.7 到 X.2
- XII.11 至 VII.5
- XII.13 至 VII.5 和 XII.11
到目前为止的代码:
library(shiny)
library(dplyr)
library(plotly)
# Define UI for application that draws a line-connected donut chart
ui <- fluidPage(
plotlyOutput("plot"),)
server <- function(input,output,session) {
dtRutte3 <- read.csv("Herverkaveling.Rutte3.csv",sep=';',dec=',',fileEncoding="Windows-1252")
# Read csv containing the internally connecting lines
dtHerverkavelingen <- read.csv("Herverkavelingen.Rutte3.csv")
# Filter out chapters and articles
dtChapters <- dtRutte3 %>%
group_by(parents) %>%
filter(parents=='root') %>%
ungroup()
dtArticles <- dtRutte3 %>%
group_by(parents) %>%
filter(parents!='root') %>%
ungroup()
# Render the donut
output$plot <- renderPlotly({
fig <- plot_ly(height=1024,sort=FALSE)
# Outer donut containing chapters
fig <- add_trace(fig,hole = '0.75',type = 'pie',rotation = 0,textposition = 'inside',textinfo = 'label',insidetextfont = list(color = '#FFFFFF'),hoverinfo = 'text',text = ~paste(dtChapters$ids,': ',dtChapters$labels),labels = dtChapters$ids,values = dtChapters$values,showlegend=FALSE,domain = list(x = c(0.1,0.9),y = c(0,1))
)
# Inner donut containing articles
fig <- add_trace(fig,rotation = 14.4,# somehow the inner donut is skewed?
textposition = 'inside',text = ~paste(dtArticles$ids,dtArticles$labels),labels = dtArticles$ids,values = dtArticles$values,domain = list(x = c(0.2,0.8),y = c(0.1,0.9))
)
fig <- fig %>% layout(title="Herverkaveling Rutte 3")
fig
#add_lines? add_trace? how to calculate coordinates?
})
}
shinyApp(ui,server)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)