Gráficos Sankey ou Alluvial

Representação do fluxo
News
Author
Published

February 25, 2019

Sankey plot representes the information flow.

The plot below shows how information from different business areas were addressed during the Fit & Gap Sesssions.

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.4.4     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(gt)
library(gtsummary)
library(readxl)
library(networkD3)

in_data1 <- read_excel(path = "~/workspace/ALA/fit and bid analysis/ABR BID and Change Impact Tracker.xlsx",
                 sheet = "Parking Lot") |> 
  janitor::clean_names() 

links <- 
  in_data1 |> 
  select(stream, moved_to) |> 
  rename(source = stream, target = moved_to) |> 
  select(source, target) |> 
  mutate(value = 1,
         target = if_else(is.na(target) | str_detect(target, "N/A"), "Closed", target)) |>
  filter(!is.na(source)) 

links <- 
  links |> 
  mutate(group = factor(source))
  
nodes <- tibble(
  name = c(as.character(links$source), as.character(links$target)) |> unique()
)

links <- 
  links |> 
  mutate(IDsource = match(links$source, nodes$name)-1,
         IDtarget = match(links$target, nodes$name)-1)


colors_group <- links$group |> unique() |> as.character() 
my_color <- 'd3.scaleOrdinal() .domain(["MAS", "DTC", "B2B/ O2C/ DTC", "O2C", "B2B", "SCM", "SCM/MAS", "DTC/ FIN", "FIN/ SCM", "FIN", "MAS/ O2C", "DTC/ MAS", "SCM/REP", "B2B/ O2C", "FIN/ MAS", "FIN/ O2C", "SCM/FIN"]) .range(["#ffff55", "#cc4444", "#33aabb",  "#bb9988", "#ea7766", "#bf4499", "#33aabb", "#33aabb", "#33aabb", "#9f4400", "#33aabb", "#33aabb", "#33aabb", "#33aabb", "#33aabb", "#33aabb", "#33aabb"])'

sankeyNetwork(Links = links, 
              Nodes = nodes,
              Source = "IDsource",
              Target = "IDtarget",
              Value = "value",
              NodeID = "name",
             # colourScale = my_color,
              LinkGroup = "group",
              sinksRight = FALSE,
            nodeWidth = 40,
            fontSize = 14)
Links is a tbl_df. Converting to a plain data frame.
Nodes is a tbl_df. Converting to a plain data frame.

Taken the information that was carried to a BID evaluation process - FMS GAPs (BIDs) - this is how they were addressed during the evaluation of BIDs process:

in_data_s2 <- read_excel(path = "~/workspace/ALA/fit and bid analysis/ABR BID and Change Impact Tracker.xlsx",
                 sheet = "FMS GAPs (BIDs)",
                 skip = 1) |> 
  janitor::clean_names()

links <- 
  in_data_s2 |> 
  filter(!is.na(stream)) |> 
  select(stream, status, effort_days_total, description, comment) |> 
  rename(source = stream, target = status, value = effort_days_total) |> 
  filter(!is.na(value))


links <- 
  links |> 
  mutate(group = factor(source),
         value = 1)
  
nodes <- tibble(
  name = c(as.character(links$source), as.character(links$target)) |> unique()
)

links <- 
  links |> 
  mutate(IDsource = match(links$source, nodes$name)-1,
         IDtarget = match(links$target, nodes$name)-1)

sankeyNetwork(Links = links, 
              Nodes = nodes,
              Source = "IDsource",
              Target = "IDtarget",
              Value = "value",
              NodeID = "name",
              LinkGroup = "group",
               sinksRight = FALSE,
            nodeWidth = 40,
              fontSize = 22)
Links is a tbl_df. Converting to a plain data frame.
Nodes is a tbl_df. Converting to a plain data frame.

O que foi Cancelado?

links |> 
  filter(str_detect(target, "Cancel")) |> 
  arrange(source) |> 
  gt()
source target value description comment group IDsource IDtarget
B2B 99. Cancelled 1 Order confirmation report Order confirmations are not sent per sales order. Currently the customer checks his orders on Asics.net. Global BID planned for 2024 - Cancelled as orders are created live to FMS the user can see immediately in order history. No confirmation required B2B 7 11
B2B 99. Cancelled 1 Brand portal assets - 360 images on B2B 06/12 TZ: to be covered by 101772 in item 97 22/11 BO: Global requirement. Effort 4 days. Will be delivered as part of the 2024 portfolio. Not all assets are shot and loaded into the brand portal. This would need to be approved by ADI currently the quality doesn't not meet global standards. Is Brazil able to load images to Brand portal for locally produced product. 360 image are a nice to have but not a must have. B2B 7 11
DTC 99. Cancelled 1 ABR - Baseline configuration - Localization 01/12 BO: Integrated in BID 101484. Cancelled this one. Setup localization topics for DTC DTC 3 11
FIN 99. Cancelled 1 Tax calculation mismatches 22/11 BO: Replaced by (Base) Location per Team, this is covered by the FIN Localization topic. Generic GAP for possible mismatches related to tax in both SCM and O2C pricing. FIN 4 11
FIN 99. Cancelled 1 Approval of journal entries 29/11: JS: Provided solution of Park/Post is accepted by the ABR team (Ives and Fabricio). 22/12 BO: Currently there is a solution in BPM. In my view this requirement must be challenged. Not part of Global template. Park/ Post functionality or Report to review executed manual posting. Journal entries are currently being approved by the business. We don't have a solution in FMS for this. Will this be covered in the BPM tool? FIN 4 11
FIN 99. Cancelled 1 ABR - Baseline configuration - Localization 01/12 BO: Integrated in BID 101485. Cancelled this one. Setup localization topics for FIN, for now the tax benefit topic is part of this estimate but it depends if standard SAP can cover dealing with this. FIN 4 11
MAS 99. Cancelled 1 Local pictures management 07/12 BO I cancelled this FMS Gap. No software topic 29/11 BO: No software change needed More process related MAS 0 11
MAS 99. Cancelled 1 Customer delivery schedule Customers can indicate when they want to be delivered (days & time) 16/11 - CM: discussed with O2C. Requirement will be covered with Customer VAS. MAS 0 11
MAS 99. Cancelled 1 Customised assortments in Brazil This will be solved with GAP#52 or stadard solution will be used. MAS 0 11
MAS 99. Cancelled 1 Product description in PT Needed at product creation - to be discussed if we can use the existing FMS upload or we need to intervene upstream 23/11 - CM: MAS 0 11
O2C 99. Cancelled 1 Sales order upload tool 07/12 BO: Cancelled this Gap. Effort estimation was 4 days in total. 07/12 LSC: this functionality is already supported by the current SO Upload The sales order upload tool splits on PO number. ABR wants it to split on RDD O2C 2 11
O2C 99. Cancelled 1 ABR - Baseline configuration - Localization 01/12 BO: Integrated in BID 101483. Cancelled this one. Setup localization topics for O2C other than pricing: '- NFe generation, setup DRC for O2C - XML generation and mapping - Printing and form of DANFE, CCC (NF correction letter) and Simplified NFe (PL SAP BE: OTC_011_BR) - XML for carrier PL SAP BR OTC_007_BR O2C 2 11
O2C 99. Cancelled 1 O2C-E-Invoicing and DRC included in #89 '- NFe generation, setup DRC for O2C - XML generation and mapping - Printing and form of DANFE, CCC (NF correction letter) and Simplified NFe (PL SAP BE: OTC_011_BR) - XML for carrier PL SAP BR OTC_007_BR O2C 2 11
SCM 99. Cancelled 1 Different purchase prices needed for Fedex and WilsonSons for local purchasing. Both DC's have the same site. 13/12 WV: Vanessa confirmed that 1 Purchasing price will be negociated for both Fedex and Wilson Sons --> Closed. (No estimate was given) 29/11 BO: Wilder will discuss this topic with rBPO. - Having 1 price for both Fedex and Wilson Sons is costing R$ 240.000 in 10 months. - Manual pricing in the PO is not an option according to Vanessa. Frequency to WS Cleared is once a month - To check with Tatiana if an additional price condition is an option with DRC SCM 1 11
SCM 99. Cancelled 1 Possibility needed to change address on Ecom delivery after Goods Issue 30/11 WV: Aligned with Vanessa. Can be cancelled 24/11 BO: Challenged by Alberto if really needed. Used for re-delivery of ecom deliveries with incorrect address SCM 1 11
SCM 99. Cancelled 1 Several interfaces Partner = Brokers Brokers will work in Thomson Reuters SCM 1 11
SCM 99. Cancelled 1 Several interfaces Partner = Arquivei Out of scope - replaced by VIM & DRC (Jurriaan and Bert) SCM 1 11
SCM 99. Cancelled 1 Several interfaces Partner = VTEX - Tracking information to VTEX Included in the DTC stream SCM 1 11
SCM 99. Cancelled 1 Adapt Buy-Via process for ZPB Back-to-Back via Wilson Sons (ACL/ACO buy from local ABR vendor) 24/11 BO: Ward discussed with Vanessa and they agreed to do this manual. BID cancelled. SCM 1 11
SCM 99. Cancelled 1 Support change of direct shipment to purchasing for stockm, based on use of Back to back process: - Change output to local vendor - Changes related AOS - Changes in APL interface - Remove sales order assignment of stock - Change of site of PO - ….... 12/12 WV: Processes discussed in case orders are cancelled. Standard SAP with a lot of work. Import process still to be checked. ==> Cancelled (Estimate was 45 days) 24/11 BO: How do other regions handle this exception? In my view the customer should accept the goods and if the customer doesn't want the goods, they can return it. Ward will discuss further if this process is really needed. Used in case a customer of Back-to-Back stock cancels the purchase. Should work for warehouses with a WM and Without a WM SCM 1 11
SCM 99. Cancelled 1 ABR - Baseline configuration - Localization 01/12 BO: Integrated in BID 101482. Cancelled this one. Setup localization topics for SCM SCM 1 11

Deviation from the Global Way of Working

in_data_s2 |> 
  filter(!is.na(stream)) |> 
  filter(!str_detect(status, "99. Cancelled")) |> 
  filter(!is.na(charm_number)) |> 
  filter(!str_detect(charm_number, "Wait")) |> 
  filter(!str_detect(charm_number, "NA")) |> 
  select(stream, charm_number, bid_classification) |> 
  count(stream, bid_classification, sort = T) |> 
  filter(!is.na(bid_classification)) |>
  filter(!str_detect(bid_classification, "NA")) |>
  filter(!str_detect(bid_classification, "template")) |> 
  mutate(bid_classification = case_when(
    str_detect(bid_classification, "Legal") ~ "Legal Requirement",
    str_detect(bid_classification, "Integration") ~ "3rd Party Integration",
    str_detect(bid_classification, "Waiting") ~ "3rd Party Integration",
    TRUE ~ bid_classification
  )) |> 
  count(stream, bid_classification, wt = n) |> 
  group_by(stream) |> 
  mutate(`Total by Area` = sum(n)) |> 
  ungroup() |> 
  pivot_wider(names_from = bid_classification,
              values_from = n) |> 
  relocate(`Legal Requirement`, .after = last_col()) |> 
  relocate(`3rd Party Integration`, .after = last_col()) |> 
  relocate(`Baseline & Localization`, .after = last_col()) |> 
  relocate(`Deviation from Global way of working`, .after = last_col()) |> 
  relocate(`Total by Area`, .after = last_col()) |> 
  arrange(`Total by Area`) |>
  # mutate(color = "") |> 
  gt(rowname_col = "stream") |> 
  tab_header(
    title = md(paste("BID Quantities", fontawesome::fa("city") , "FMS-SAP")),
    subtitle = "Status at 2023-12-19"
  ) |>
  sub_missing()  |> 
  grand_summary_rows(
    # columns = -c(color),
     fns = list(
      total = ~ sum(., na.rm = TRUE)
    )
  ) |> 
  tab_options(
    table.font.size = 24
  ) |> 
  tab_style(
    style = list(
      cell_fill(color = "darkred"),
      cell_text(color = "white")),
    locations = cells_grand_summary(
      columns = `Deviation from Global way of working`,
      rows = 1
    )
  ) |> 
  # data_color(
  #   columns = `3rd Party Integration`,
  #   rows =  `3rd Party Integration` > 5,
  #   method = "numeric",
  #   palette = c("lightblue", "pink"),
  #   domain = c(0, 10)
  # )  |> 
  cols_label(
    `Legal Requirement` = "Legal<br>Requirement",
    `3rd Party Integration` = "3rd Party<br>Integration",
    `Baseline & Localization` = "Baseline &<br>Localization",
    `Deviation from Global way of working` = "Deviation<br>from Global<br>way of<br>working",
    `Total by Area` = "Totals",
    .fn = md
  ) |> 
  data_color(
    columns = `Total by Area`,
    #rows =  `Total by Area` > 15,
    method = "numeric",
    palette = c("lightblue", "pink"),
    domain = c(0, 16)
  ) 
BID Quantities FMS-SAP
Status at 2023-12-19
Legal
Requirement
3rd Party
Integration
Baseline &
Localization
Deviation
from Global
way of
working
Totals
AUTH 1 1
REP 1 1
B2B 1 1 2
O2C 4 3 3 10
DTC 2 7 1 2 12
FIN 4 5 1 2 12
MAS 3 5 3 1 12
SCM 4 8 2 2 16
total 18 25 12 11 66

teste

countrypops |>
  dplyr::filter(country_code_3 %in% c("FRA", "GBR")) |>
  dplyr::filter(year %% 10 == 0) |>
  dplyr::select(-contains("code")) |>
  dplyr::mutate(color = "") |>
  gt(groupname_col = "country_name") |>
  fmt_integer(columns = population) |>
  data_color(
    columns = population,
    target_columns = color,
    method = "numeric",
    palette = "viridis",
    domain = c(4E7, 7E7)
  ) |>
  cols_label(
    year = "",
    population = "Population",
    color = ""
  ) |>
  opt_vertical_padding(scale = 0.65)
Population
France
1960 46,649,927
1970 51,724,116
1980 55,052,582
1990 58,044,701
2000 60,921,384
2010 65,030,575
2020 67,571,107
United Kingdom
1960 52,400,000
1970 55,663,250
1980 56,314,216
1990 57,247,586
2000 58,892,514
2010 62,766,365
2020 67,081,234

Citation

BibTeX citation:
@misc{abreu2019,
  author = {Abreu, Marcos},
  title = {Gráficos Sankey ou Alluvial},
  date = {2019-02-25},
  url = {https://abreums.github.io/posts/2012-12-15-sankey-plot/},
  langid = {pt-br}
}
For attribution, please cite this work as:
Abreu, Marcos. 2019. “Gráficos Sankey ou Alluvial.” February 25, 2019. https://abreums.github.io/posts/2012-12-15-sankey-plot/.