r4fun / hierplane

🌳 Hierplane for R
https://r4fun.github.io/hierplane/
Other
9 stars 0 forks source link

Split settings styles #36

Closed mathidachuk closed 4 years ago

mathidachuk commented 4 years ago

Closes #34

Had to change styles (list of available style options) back to style_options so the name does not conflict with the param name..

Also WHHOOOOPS just realized i committed the custom theming stuff to the wrong branch. It does not impact the functionality of the app/this branch tho so I am going to leave it.

Sorry for wall of text for example 🌺


structure(list(parent_id = c("Star Wars Movies", "Star Wars Movies",
                             "Star Wars Movies", "Star Wars Movies", "Original", "Prequel",
                             "Original", "Original", "Sequel", "Prequel", "Prequel", "Ep 1",
                             "Ep 1", "Ep 1", "Ep 1", "Ep 1", "Ep 1", "Ep 1", "Ep 1", "Ep 1",
                             "Ep 2", "Ep 2", "Ep 2", "Ep 2", "Ep 2", "Ep 2", "Ep 2", "Ep 2",
                             "Ep 3", "Ep 3", "Ep 3", "Ep 3", "Ep 3", "Ep 3", "Ep 3", "Ep 3",
                             "Ep 3", "Ep 3", "Ep 3", "Ep 4", "Ep 4", "Ep 4", "Ep 4", "Ep 4",
                             "Ep 4", "Ep 4", "Ep 4", "Ep 4", "Ep 5", "Ep 5", "Ep 5", "Ep 5",
                             "Ep 5", "Ep 5", "Ep 5", "Ep 5", "Ep 5", "Ep 5", "Ep 6", "Ep 6",
                             "Ep 6", "Ep 6", "Ep 6", "Ep 6", "Ep 6", "Ep 6", "Ep 6", "Ep 6",
                             "Ep 6", "Ep 7", "Ep 7", "Ep 7", "Ep 7"),
               child_id = c("Star Wars Movies",
                            "Original", "Prequel", "Sequel", "Ep 5", "Ep 3", "Ep 6", "Ep 4",
                            "Ep 7", "Ep 2", "Ep 1", "Belbullab-22 starfighter", "H-type Nubian yacht",
                            "Jedi Interceptor", "Jedi starfighter", "Naboo fighter", "Naboo Royal Starship",
                            "Naboo star skiff", "Scimitar", "Trade Federation cruiser", "Belbullab-22 starfighter",
                            "H-type Nubian yacht", "Jedi Interceptor", "Jedi starfighter",
                            "Naboo fighter", "Naboo star skiff", "Slave 1", "Trade Federation cruiser",
                            "Belbullab-22 starfighter", "H-type Nubian yacht", "Imperial shuttle",
                            "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                            "Naboo fighter", "Naboo star skiff", "TIE Advanced x1", "Trade Federation cruiser",
                            "X-wing", "Belbullab-22 starfighter", "Imperial shuttle", "Jedi Interceptor",
                            "Jedi starfighter", "Millennium Falcon", "Naboo star skiff",
                            "TIE Advanced x1", "Trade Federation cruiser", "X-wing", "Belbullab-22 starfighter",
                            "Imperial shuttle", "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                            "Naboo star skiff", "Slave 1", "TIE Advanced x1", "Trade Federation cruiser",
                            "X-wing", "A-wing", "Belbullab-22 starfighter", "Imperial shuttle",
                            "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                            "Naboo star skiff", "Slave 1", "TIE Advanced x1", "Trade Federation cruiser",
                            "X-wing", "Imperial shuttle", "Millennium Falcon", "T-70 X-wing fighter",
                            "X-wing"),
               child = c("Star Wars Movies", "Original", "Prequel",
                         "Sequel", "The Empire Strikes Back", "Revenge of the Sith", "Return of the Jedi",
                         "A New Hope", "The Force Awakens", "Attack of the Clones", "The Phantom Menace",
                         "Belbullab-22 starfighter", "H-type Nubian yacht", "Jedi Interceptor",
                         "Jedi starfighter", "Naboo fighter", "Naboo Royal Starship",
                         "Naboo star skiff", "Scimitar", "Trade Federation cruiser", "Belbullab-22 starfighter",
                         "H-type Nubian yacht", "Jedi Interceptor", "Jedi starfighter",
                         "Naboo fighter", "Naboo star skiff", "Slave 1", "Trade Federation cruiser",
                         "Belbullab-22 starfighter", "H-type Nubian yacht", "Imperial shuttle",
                         "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                         "Naboo fighter", "Naboo star skiff", "TIE Advanced x1", "Trade Federation cruiser",
                         "X-wing", "Belbullab-22 starfighter", "Imperial shuttle", "Jedi Interceptor",
                         "Jedi starfighter", "Millennium Falcon", "Naboo star skiff",
                         "TIE Advanced x1", "Trade Federation cruiser", "X-wing", "Belbullab-22 starfighter",
                         "Imperial shuttle", "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                         "Naboo star skiff", "Slave 1", "TIE Advanced x1", "Trade Federation cruiser",
                         "X-wing", "A-wing", "Belbullab-22 starfighter", "Imperial shuttle",
                         "Jedi Interceptor", "Jedi starfighter", "Millennium Falcon",
                         "Naboo star skiff", "Slave 1", "TIE Advanced x1", "Trade Federation cruiser",
                         "X-wing", "Imperial shuttle", "Millennium Falcon", "T-70 X-wing fighter",
                         "X-wing"),
               link = c("ROOT", "Original", "Prequel", "Sequel",
                        "Ep 5", "Ep 3", "Ep 6", "Ep 4", "Ep 7", "Ep 2", "Ep 1", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                        "ship", "ship", "ship", "ship", "ship"),
               node_type = c("ROOT",
                             "Original", "Prequel", "Sequel", "Original", "Prequel", "Original",
                             "Original", "Sequel", "Prequel", "Prequel", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship", "ship", "ship", "ship", "ship", "ship",
                             "ship", "ship", "ship"),
               timeline = c(NA, "Original", "Prequel",
                            "Sequel", "Original", "Prequel", "Original", "Original", "Sequel",
                            "Prequel", "Prequel", NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                            NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                            NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                            NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                            NA, NA, NA, NA),
               films = c(NA, NA, NA, NA, "The Empire Strikes Back",
                         "Revenge of the Sith", "Return of the Jedi", "A New Hope", "The Force Awakens",
                         "Attack of the Clones", "The Phantom Menace", NA, NA, NA, NA,
                         NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                         NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                         NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                         NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
               episode = c(NA, NA,
                           NA, NA, "Ep 5", "Ep 3", "Ep 6", "Ep 4", "Ep 7", "Ep 2", "Ep 1",
                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                           NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
               film_year = c(NA,
                             NA, NA, NA, "1980", "2005", "1983", "1977", "2015", "2002", "1999",
                             NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                             NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                             NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                             NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
               attribute1 = c(NA,
                              NA, NA, NA, "1980", "2005", "1983", "1977", "2015", "2002", "1999",
                              NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                              NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                              NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
                              NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
               attribute2 = list(
                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                 NULL, "Obi-Wan Kenobi", "Padmé Amidala", 
                 c("Obi-Wan Kenobi",
                   "Anakin Skywalker"), 
                 c("Obi-Wan Kenobi", "Plo Koon"),
                 c("Anakin Skywalker",
                   "Padmé Amidala"), "Ric Olié", c("Obi-Wan Kenobi", "Padmé Amidala"
                   ), "Darth Maul", c("Obi-Wan Kenobi", "Anakin Skywalker"),
                 "Obi-Wan Kenobi", "Padmé Amidala", c("Obi-Wan Kenobi", "Anakin Skywalker"
                 ), c("Obi-Wan Kenobi", "Plo Koon"), 
                 c("Anakin Skywalker",
                   "Gregar Typho", "Padmé Amidala"),
                 c("Obi-Wan Kenobi", "Padmé Amidala"), 
                 "Boba Fett", c("Obi-Wan Kenobi", "Anakin Skywalker"),
                 c("Obi-Wan Kenobi", "Grievous"), "Padmé Amidala", 
                 c("Luke Skywalker",
                   "Chewbacca"), c("Obi-Wan Kenobi", "Anakin Skywalker"),
                 c("Obi-Wan Kenobi","Plo Koon"), "Chewbacca", 
                 c("Anakin Skywalker", "Padmé Amidala"), 
                 c("Obi-Wan Kenobi", "Padmé Amidala"), "Darth Vader",
                 c("Obi-Wan Kenobi",
                   "Anakin Skywalker"), "Luke Skywalker", "Obi-Wan Kenobi",
                 c("Luke Skywalker", "Chewbacca", "Han Solo"), "Obi-Wan Kenobi",
                 "Obi-Wan Kenobi", c("Chewbacca", "Han Solo"), "Obi-Wan Kenobi",
                 "Darth Vader", "Obi-Wan Kenobi",
                 c("Luke Skywalker", "Biggs Darklighter",
                   "Wedge Antilles", "Jek Tono Porkins"), "Obi-Wan Kenobi",
                 c("Luke Skywalker", "Chewbacca", "Han Solo"), "Obi-Wan Kenobi",
                 "Obi-Wan Kenobi", c("Chewbacca", "Han Solo", "Lando Calrissian"
                 ), "Obi-Wan Kenobi", "Boba Fett", "Darth Vader", "Obi-Wan Kenobi",
                 c("Luke Skywalker", "Wedge Antilles"), "Arvel Crynyd", "Obi-Wan Kenobi",
                 c("Luke Skywalker", "Chewbacca", "Han Solo"), "Obi-Wan Kenobi",
                 "Obi-Wan Kenobi", c("Chewbacca", "Han Solo", "Lando Calrissian",
                                     "Nien Nunb"), "Obi-Wan Kenobi", "Boba Fett", "Darth Vader",
                 "Obi-Wan Kenobi", c("Luke Skywalker", "Wedge Antilles"),
                 c("Luke Skywalker", "Chewbacca", "Han Solo"), 
                 c("Chewbacca",
                   "Han Solo"), "Poe Dameron", "Luke Skywalker")),
          class = "data.frame", row.names = c(NA,
                                              -73L))

# use all default settings
hierplane(hp_dataframe(hp_starwars))

# apply settings independent from styles (only show attribute1 ships (no name labels))
hierplane(hp_dataframe(hp_starwars, 
                       settings = hierplane_settings(attributes = "attribute1"))) 

# apply custom styling independent from settings
hierplane(hp_dataframe(
  hp_starwars,
  styles = hierplane_styles(
    node_type_to_style = list(
      ROOT = c("color1", "strong"),
      Prequel = "color3",
      Original = "color4",
      Sequel = "color2",
      ship = "color6"
    ),
    link_to_positions = list(Prequel = "left",
                             Original = "right"),
    link_name_to_label = list(
      Prequel = "arc",
      Sequel = "arc",
      Original = "arc"
    )
  )
))
tylerlittlefield commented 4 years ago

I've made two small changes: