A timeline in memory of David Bowie

A timeline in memory of David Bowie

Creating a timeline using R

Overview

What was made: 

On Jan 10, 2017 David Bowie left this earthly realm. That day, as I do like his music a lot, I decided to create a timeline and recently I decided to make the code publicly available. I used R for this project.

Background and objectives: 

His music touched me so I wanted to do something and I made this timeline. To replicate this, or creating your own timeline, you need a CSV file and rCharts.

Outcome: 

Here's the full project on Github: https://github.com/pachamaltese/bowie-timeline
And here is the timeline: http://pacha.hk/bowie-timeline/

How it was made

CSV file

Create a CSV file whose basic columns are

  • Start Date
  • End Date
  • Headline
  • Text
  • Media
  • Media Credit
  • Media Caption
  • Media Thumbnail
  • Type
  • Tag

The only tricky part is that in Excel, Google Sheets or any other cellsheet software both start and end date must be formatted as m/d/yy hh:mm.

Feeling during this step: 
0
No
Loading packages
setwd("/Users/pacha/bowie-timeline/") #change this to your working folder
library(plyr)
library(RCurl)
library(rCharts)

If rChart is not installed it can be installed using devtools. The package website shows some deprecated parameters and this is what works.

require(devtools)
install_github('ramnathv/rCharts')
Feeling during this step: 
0
No
Reading data
discography <- read.csv("discography.csv", as.is = TRUE)
discography <- alply(discography, 1, function(x) {
  list(startDate = x$Start.Date, headline = x$Headline, text = x$Text, 
       asset = list(media = x$Media))
})
Feeling during this step: 
0
No
Creating timeline
tl = Timeline$new()
tl$main(headline = paste0("David Bowie"), type = "default", text = paste0("Discography ", 
        format(as.Date("1967-01-01"), "%Y"), "-", format(as.Date("2016-01-01"), "%Y")), 
        startDate = format(as.Date("1967-01-01"), "%Y"), asset = list(media = "img/cover.jpg"))
names(discography) <- NULL
tl$event(discography)

tl$save("index.html")
Feeling during this step: 
0
No
Adjustments

Daisuke Ichikawa's blog has a solution to change the JS path without editing the final html outside RStudio. This are the steps, do them or the timeline won't work in other computer.

js <- paste(readLines("index.html", warn = F), collapse = "\n")
js <- gsub("/Users/pacha/bowie-timeline/timeline/js/storyjs-embed.js", 
          "timeline/js/storyjs-embed.js", 
          js)
writeLines(js, con = "index.html")

Now, if you open your timeline the dates are displayes as dd/mm/yyyy hh:mm, if you want to show years only then open the html in your editor, look for startDate and the dates will be shown as "1/1/1967 00:00", you can change it to "1967" without further steps but do the same to any startDate (e.g. use replace "1/1/" for "" in your editor).

Feeling during this step: 
0
No
Optional step

The final step is to go to the timeline folder that you just copied and get hands into the CSS file, then add the Creative Commons button and favicon, and then you will obtain exactly the same result as me. You can also add Google Analytics code to your timeline as with any html file.

Feeling during this step: 
0
No
Verification

To avoid many commits to Github, you can run this from terminal

cd /Users/pacha/bowie-timeline
python -m SimpleHTTPServer 8000

and then in your brower go to http://localhost:8000/ to see your changes.

Feeling during this step: 
0
No