- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个数据框,其中包含不同团队执行的任务的信息。
我想使用 R.Blue box = team 绘制类似的图,如下所示。任务已完成 = 绿框。执行任务=灰框。我正在考虑使用 ggplot2 geom_tile 来实现此目的,但我想知道是否还有其他现有的解决方案?
示例:
task team status
1 A completed
2 A completed
3 B completed
4 A to do
5 C to do
6 B to do
7 C to do
8 A to do
dput
用于再现性:
structure(list(task = 1:8, team = c("A", "A", "B", "A", "C",
"B", "C", "A"), status = c("completed", "completed", "completed",
"to do", "to do", "to do", "to do", "to do")), .Names = c("task",
"team", "status"), class = "data.frame", row.names = c(NA, -8L
))
<小时/>
最佳答案
我没有找到现有的解决方案,所以我编写了一个可以满足您需要的函数。当然,对于大数据集,它会给出不合适的结果。
require(dplyr)
timeline_plot <- function(dat, spacing = 0.01, team_size = 0.25, notch = 0.1,
cols = list(team = "lightblue",
completed = "green3",
"to do" = "lightgray"),
cex_label = 2){
# Arguments:
# dat = data frame
# spacing = space between polygons (part of plot width)
# team_size = size of team polygon (part of plot width)
# notch = size of arrow side protruding (part of plot width)
# cols = color for each status
# cex_lab = cex of labels
# Count number of columns
dat_n <- dat %>%
group_by(team) %>%
summarise(n = length(team))
# Get number of rows
nr <- length(dat_n$team)
# Prepare polygon
poly <- matrix(c(0, 0, 0, 1, 1, 1, 0, 0.5, 1, 1, 0.5, 0), ncol = 2)
# Function for polygon scaling, shifting and notch adding
morph_poly <- function(poly, scale_x = 1, shift_x = 0, notch){
poly[, 1] <- poly[, 1] * scale_x + shift_x
poly[c(2, 5), 1] <- poly[c(2, 5), 1] + notch
return(poly)
}
# Fucntion for label positioning
label_pos_x <- function(poly){
x <- poly[2, 1] + (poly[5, 1] - poly[2, 1]) / 3
return(x)
}
# Save old par
opar <- par()
# Set number of rows for plotting
par(mfrow = c(nr, 1))
par(mar = c(0,0,0,0))
# Actual plotting
for (i in c(1:nr)){
# Each row will be presentd as
# team_polygon + spacing + n * (spacing + task_polygon) + notch
team <- dat_n$team[i]
tasks <- dat[dat$team == team, ]
tasks <- tasks[order(tasks$task), ]
# Create empty plot
plot(NA, xlim = c(0, 1), ylim = c(0, 1), xlab = "", ylab = "", bty = "n", xaxt = "n", yaxt = "n")
# Plot team polygon
team_poly <- morph_poly(poly, team_size, 0, notch)
polygon(team_poly, col = cols$team)
# Add team label
text(label_pos_x(team_poly), 0.5, labels = dat_n$team[i], cex = cex_label)
# Calculate the size of task polygon
tasks_n <- dat_n$n[i]
size_x <- (1 - team_size - (tasks_n * spacing) - notch) / tasks_n
shift <- team_size + spacing
# plot each task polygon
for (j in 1:nrow(tasks)){
# Get task color
task_col = cols[[tasks$status[j]]]
# Prepare polygon
task_poly <- morph_poly(poly, scale_x = size_x, shift_x = shift + spacing, notch = notch)
polygon(task_poly, col = task_col)
# Add task label
text(label_pos_x(task_poly), 0.5, labels = tasks$task[j], cex = cex_label)
# Update shift
shift <- shift + size_x + spacing
}
}
# Set initial par
par(opar)
}
将您的数据集设置为 dat
它给出:
timeline_plot(dat)
关于R : Draw timeline flowchart,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54107239/
我在 Obsidian 和 Wordpress 中使用 Mermaid。在两者中,以下短图都有覆盖标题的连接箭头: 有什么办法可以在不使用 CSS 或更改为水平方式的情况下解决这个问题吗? flo
我最近正在研究一些其他聪明人编写的冗长而晦涩的代码。 我正在考虑生成数据流程图和流程图以方便我的工作。是否有任何软件可以自动完成此工作? P.S.大多数代码在C和Fortran中。 最佳答案 数据流图
下面是代码理解的逆向工程。所以这里是函数: void deleteTask(TaskPtr& head, const char* fullName) { TaskPtr current, no
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我想知道为什么我们使用数据流程图而不是流程图。 最佳答案 流程图详细说明了要遵循的流程。 DFD 详细说明了系统中的数据流。 在流程图中,箭头表示元素之间的控制(而不是数据)转移,元素是指令或决策(或
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题吗? 更新问题,以便 editing this post 提供事实和引用来回答它. 关闭 5 年前。 Improve
在互联网上的各个页面上,我阅读了有关流程图的内容,并尝试查找有关我可以在各种情况/上下文中使用哪些框图符号的信息。 我找到了 ECMA-4 创建的标准和IBM,但第一个是1966年的,第二个是1970
我正在为非技术用户制作快速而肮脏的软件流程。我想要一些可以输出为 PNG 或其他图形格式的东西,并且它们可以很容易地进入并用于进行更新和修改。东西轻... 最佳答案 我喜欢 yEd .它有一个简单而强
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
有人知道如何在 EA 中绘制流程图的教程吗?我在使用连接器时遇到问题。如果可能的话,如何在没有其他连接器的情况下连接它? 最佳答案 首先检查您是否真的在绘制流程图 - 应该是这样的:插入图 -> 战略
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我有一个数据框,其中包含不同团队执行的任务的信息。 我想使用 R.Blue box = team 绘制类似的图,如下所示。任务已完成 = 绿框。执行任务=灰框。我正在考虑使用 ggplot2 geom
我很高兴认识这么棒的软件,graph-easy。但是我不能提供更多关于它的文档。所以请有人帮助我。这是我的代码: [Client] { size: 5,10;} [Msg Server] { size
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
flowchart.js 是否支持单击事件处理程序?谁能帮我使用 flowchart.js 为节点定义事件处理程序 最佳答案 您可以为节点点击添加一个 javascript 函数。取下面的定义: op
我正在使用 flowchart.js用于获取流程图的 SVG 渲染的库。我需要在带有动态 Bootstrap 面板的弹出窗口中包含流程图渲染,但结果一团糟(盒子上的标签和小渲染: 我的代码是:
我正在研究 Kendo UI 图表工具,很惊讶地发现没有传统流程图或工作流程图的示例。所有示例似乎都是组织结构图的迭代,形状为圆形或矩形。 http://demos.telerik.com/kendo
我想使用JQuery.flowchart Angular 为 6。 我刚刚创建了一个简单的代码,如下所示。 HTML(app.component.html) jQuery flowchart.
我正在使用 Sebastien 的这个 jquery 插件 https://github.com/sdrdis/jquery.flowchart 它是一个开源 ui 插件,我可以用它来绘制我正在开发的
我是一名优秀的程序员,十分优秀!