Dataviz Makeover 2

Setting Up Environment

p <- c('igraph', 'tidygraph', 'ggraph', 'visNetwork', 'lubridate', 'tidyverse', 'ggrepel')
lapply(p, require, character.only = TRUE)

Data Wrangling

GAStech_nodes <- read_csv("data/GAStech_email_node.csv")
GAStech_edges <- read_csv("data/GAStech_email_edge-v2.csv")

GAStech_edges$SentDate  = dmy(GAStech_edges$SentDate)
GAStech_edges$Weekday = wday(GAStech_edges$SentDate, label = TRUE, abbr = FALSE)

GAStech_edges_aggregated <- GAStech_edges %>%
  filter(MainSubject == "Work related") %>%
  group_by(source, target, Weekday) %>%
  summarise(Weight = n()) %>%
  filter(source!=target) %>%
  filter(Weight > 1) %>%
  ungroup()

GAStech_graph <- tbl_graph(nodes = GAStech_nodes, edges = GAStech_edges_aggregated, directed = TRUE)

GAStech_graph %>%
  activate(edges) %>%
  arrange(desc(Weight))

Task 1: Static Organisation Graph

Task Description

Improve the code chunk used to create the organisation network graph by using the latest functions provided in ggraph2.0.
Identify three aspects of the graph visualisation in Section 6.1 that can be improved.
Provide the sketch of your alternative design.
Using appropriate ggraph functions, plot the alternative design.

Original Design

g <- GAStech_graph %>%
  mutate(betweenness_centrality = centrality_betweenness()) %>%
  mutate(closeness_centrality = centrality_closeness()) %>%
  ggraph(layout = "nicely") + 
  geom_edge_link(aes()) +
  geom_node_point(aes(colour = closeness_centrality, size=betweenness_centrality))

g + theme_graph()

3 Key Aspects To Improve On

No. Problems Solutions
1. Dark colored edges block out each other when concentrated, making it hard for views to view smaller nodes Change to lighter coloured edges to show more nodes within a particular area
2. Uncertainty as to which department the node is from and the degree of betweenness centrality at a glance Segment nodes by colour according to department and also betweenness centrality shade to depict the betweenness centrality score
3. Unable to tell which person is which node at a glance Include labels for the nodes to include names of each node

Sketch of Alternative Design

Task 1 Alternative Image

Task 1 Alternative Image

Improved Design

g <- GAStech_graph %>%
  mutate(betweenness_centrality = centrality_betweenness()) %>%
  mutate(closeness_centrality = centrality_closeness()) %>%

ggraph(layout = "nicely") + 
  geom_edge_link(colour="gray") +
  geom_node_circle(aes(fill = betweenness_centrality, r = log(betweenness_centrality)/100, col = Department), size = 3) +
  geom_node_text(aes(label=label), repel = TRUE)
g + theme_graph()

Task 2: Interactive Organisation Graph

Task Description

Improve the design of the graph by incorporating the following interactivity:
 Identify three aspects of the graph visualisation in Section 7.4 that can be improved.
 Provide the sketch of your alternative design.
 Using appropriate visNetwork functions, plot the alternative design.

Data Preparation

GAStech_edges_aggregated <- GAStech_edges %>%
  left_join(GAStech_nodes, by = c("sourceLabel" = "label")) %>%
  rename(from = id) %>%
  left_join(GAStech_nodes, by = c("targetLabel" = "label")) %>%
  rename(to = id) %>%
  filter(MainSubject == "Work related") %>%
  group_by(from, to) %>%
    summarise(weight = n()) %>%
  filter(from!=to) %>%
  filter(weight > 1) %>%
  ungroup()

GAStech_edges_aggregated <- rename(GAStech_edges_aggregated, value = weight)

GAStech_nodes <- GAStech_nodes %>%
  rename(group = Department)

Original Design

GAStech_nodes$shape = "circle"

visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(highlightNearest = list(enabled = TRUE,degree = 1, labelOnly = FALSE, hover = FALSE),
                                     nodesIdSelection = TRUE,)

Key Aspects To Improve On

No. Problems Solutions
1. There is no information when you hover a node, making it hard to get instant information Allow hover function to instantly show which nodes are collected to the node that you hover over
2. There is no sign of in-degree and out-degree centrality, making it hard for the user to know which node is actually the source and which is the target Allow directional edges to show which is the target and which is the source node
3. Unable to segment selection by a specific department/group. Include an additional filter source by department to allow user to better see which nodes are part of which department
4. All nodes still have label even after clicking, this increases visual stress on the user and makes the overall graph feel cluttered Show only relevant node labels that are connected to the source node
5. Lack of information from a node when hovering, makes it hard for user to get instant information about the particular node Add a tooltip to instantly show specific information of the node upon hovering for instant access to visual information

Sketch of Alternative Design

Task 2 Alternative Image

Task 2 Alternative Image

Improved Design

GAStech_nodes$shape = "circle"
GAStech_nodes$title <- paste0("<p>Job Title: ", GAStech_nodes$Title, "<br> Name: ",GAStech_nodes$label,"</p>")
GAStech_edges_aggregated$label <- GAStech_edges_aggregated$value

visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(highlightNearest = list(enabled=TRUE, labelOnly = TRUE, hover = TRUE,degree = list(from = 1, to = 1)),
             nodesIdSelection = TRUE,
             selectedBy ="group",
             manipulation = TRUE,) %>%
  visEdges(arrows = list(
      to = list(enabled = TRUE), 
      from = list(enabled = TRUE)
    )) %>%
  visInteraction(
    tooltipDelay = NULL, 
    tooltipStyle = 'position: fixed;visibility:hidden;padding: 1px;white-space: nowrap;
 font-family: cursive;font-size:11px;font-color:black;background-color: white;',  
    tooltipStay = 300,
    zoomView = TRUE)