我用timevisin制作了一個甘特圖R。我的甘特圖中的一些條形文字很長,所以大約第 10 個單詞之后的任何內容都會被截斷。有沒有辦法將單詞包裝成第二行或第三行?
gantt <- structure(list(group = c("How FAN1 stabilises repeats", "How FAN1 stabilises repeats"
), content = c("CRISPR nuclease and SPYF", "Effect of FAN1 SPAA and MIM mutant on MLH1 binding, ICL repair and CAG instability"
), start = structure(c(1662516351.36, 1662516351.36), tzone = "UTC", class = c("POSIXct",
"POSIXt")), end = structure(c(1677242989.44, 1677242989.44), tzone = "UTC", class = c("POSIXct",
"POSIXt")), style = c("color: white; background-color: maroon;font-size:9px;word-break: break-all;",
"color: white; background-color: maroon;font-size:9px;word-break: break-all;"
), type = c("range", "range")), row.names = c(NA, -2L), class = c("tbl_df",
"tbl", "data.frame"))
groups <- data.frame(id = unique(gantt$group),
content = unique(gantt$group),
style = "font-weight: bold; font-size:10px")
timevis(data = gantt, groups = groups,
options = list(editable = TRUE, height = "600px"))
uj5u.com熱心網友回復:
您可以使用stringr::str_wrap將文本很好地包裝到所需的最大寬度。它通過插入在這種情況下不起作用的換行符來作業,因此您需要將它們替換為<br>:
library(tidyverse)
gantt %>%
mutate(content = gsub("\n", "<br>", str_wrap(content, 30))) %>%
timevis(groups = groups, options = list(editable = TRUE, height = "600px"))

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/471067.html
上一篇:如何比較同一個python字典中的值并在匹配時做一些事情
下一篇:在串列串列中插入一個值
