|
13 | 13 | ) |
14 | 14 | } |
15 | 15 | data |> |
| 16 | + dplyr::rename(dplyr::any_of(c(node_id = "group"))) |> |
16 | 17 | .group_across("PANEL", "x", "node_id", "connector") |> |
17 | 18 | dplyr::summarise(node_size = sum(.data$y)) |> |
18 | 19 | .group_across("PANEL", "x", "node_id") |> |
|
151 | 152 |
|
152 | 153 | rhs <- .group_across(data, "PANEL", "x", "group") |> |
153 | 154 | dplyr::summarise(y = max(.data$y), .groups = "keep") |> |
154 | | - order_fun() |
| 155 | + order_fun() |> |
| 156 | + dplyr::rename(y_rhs = "y") |> |
| 157 | + .group_across("PANEL", "x") |> |
| 158 | + dplyr::arrange(.data$node_order) |> |
| 159 | + dplyr::mutate(y_cum = cumsum(.data$y_rhs) - |
| 160 | + .data$y_rhs/2, |
| 161 | + n_nodes = dplyr::n_distinct(.data$group), |
| 162 | + node_rank = dplyr::row_number() - 1, |
| 163 | + ytot = sum(.data$y_rhs), |
| 164 | + align_offset = .data$y_cum + |
| 165 | + (dplyr::row_number() - 1)*params$v_space) |
155 | 166 |
|
156 | 167 | data |> |
157 | 168 | dplyr::left_join(.stage_params(data, params), "x") |> |
158 | | - dplyr::left_join( |
159 | | - rhs |> |
160 | | - .group_across("PANEL", "x") |> |
161 | | - dplyr::arrange(.data$node_order) |> |
162 | | - dplyr::mutate(y_cum = cumsum(.data$y) - |
163 | | - .data$y/2, |
164 | | - n_nodes = dplyr::n_distinct(.data$group), |
165 | | - ytot = sum(.data$y), |
166 | | - align_offset = .data$ytot + |
167 | | - (.data$n_nodes - 1)*params$v_space), |
168 | | - c("PANEL", "x", "group")) |> |
| 169 | + dplyr::left_join(rhs, c("PANEL", "x", "group")) |> |
169 | 170 | dplyr::arrange(.data$node_order) |> |
170 | 171 | dplyr::ungroup() |> |
171 | 172 | dplyr::mutate( |
172 | | - y = .data$y_cum, |
173 | | - ymin = .data$y - .data$node_size/2, |
174 | | - ymax = .data$y + .data$node_size/2, |
175 | | - xmin = .data$x, |
176 | | - xmax = .data$x) |> |
| 173 | + y = .data$y_cum, |
| 174 | + ymin = .data$y - .data$node_size/2, |
| 175 | + ymax = .data$y + .data$node_size/2, |
| 176 | + xmin = .data$x, |
| 177 | + xmax = .data$x) |> |
177 | 178 | dplyr::select(!dplyr::any_of("y_cum")) |> |
178 | 179 | .group_across("PANEL") |> |
179 | 180 | dplyr::mutate( |
|
197 | 198 | v_space = max(.data$v_space) |
198 | 199 | ) |> |
199 | 200 | .group_across("PANEL", "x", "connector") |> |
| 201 | + dplyr::arrange(.data$node_order) |> |
200 | 202 | dplyr::mutate( |
201 | | - y_offset = (rank(.data$node_order, ties.method = "first") - 1)*.data$v_space[[1]] + |
202 | | - .data$align_offset, |
| 203 | + y_offset = .data$node_rank * |
| 204 | + .data$v_space, |
203 | 205 | x_offset = ifelse(.data$split, .data$h_space* |
204 | 206 | ifelse(.data$connector == "from", .5, -.5), 0), |
205 | 207 | y = .data$y + .data$y_offset + params$nudge_y, |
|
0 commit comments