maliny12 / sugarglider

Sugarglider creates glyph maps to visualise spatio-temporal data with customisable ribbon and segment geometries.
https://maliny12.github.io/sugarglider/
Other
8 stars 0 forks source link

some codes for setup data #7

Closed huizezhang-sherry closed 4 months ago

huizezhang-sherry commented 4 months ago
data <- data |>
    dplyr::mutate(
      x = glyph_mapping(.data$x_major,
                        rescale(.data$x_minor),
                        params$width)
    )

  data <- data |>
    tidyr::pivot_longer(cols = c(.data$y_minor, .data$ymax_minor), names_to = "t", values_to = "value") |>
    dplyr::mutate(a = rescale(value)) |>
    dplyr::select(-value) |>
    tidyr::pivot_wider(names_from = "t", values_from = "a") |>
    dplyr::mutate( ymin = glyph_mapping(.data$y_major,
                                        .data$y_minor,
                                        params$height),
                   ymax = glyph_mapping(.data$y_major,
                                        .data$ymax_minor,
                                        params$height))