diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 805546a..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Luukas Pörtfors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 378cafd..0000000 --- a/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# testaustime-r - -Visualize your testaustime data with cool graphs generated with an R script using ggplot2 - -## How to use? -1. Install necessary packages (and R if you dont have it): - ```R - install.packages("httr") - install.packages("rjson") - install.packages("ggplot2") - install.packages("ggthemes") - ``` -2. Run the script (first insert your token into it): - ```sh - Rscript plot.R - ``` -3. Look at cool images - -## How does it look? -(please ignore the awful colorscheme, I'm working on it (not)) -![](./demo/language_and_duration_by_date.png) -![](./demo/project_and_duration_by_date.png) diff --git a/demo/language_and_duration_by_date.png b/demo/language_and_duration_by_date.png deleted file mode 100644 index 10dd1cb..0000000 Binary files a/demo/language_and_duration_by_date.png and /dev/null differ diff --git a/demo/project_and_duration_by_date.png b/demo/project_and_duration_by_date.png deleted file mode 100644 index 7dd2c66..0000000 Binary files a/demo/project_and_duration_by_date.png and /dev/null differ diff --git a/plot.R b/plot.R deleted file mode 100755 index d3a9784..0000000 --- a/plot.R +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env Rscript -qry <- "https://time.lajp.fi/activity/data?min_duration=1" -bearer <- "Bearer " - -library("httr") -res <- GET(qry, add_headers(Authorization=bearer)) - -library("rjson") -result <- fromJSON(content(res,as="text")) - -result <- lapply(result, function(x) { - x[sapply(x, is.null)] <- NA - unlist(x) -}) - -df <- as.data.frame(do.call("rbind", result)) - -df$duration <- strtoi(df$duration) -df$start_time <- as.Date(df$start_time) - -data <- aggregate(duration~language+project_name+start_time, data=df, FUN=sum, na.rm=TRUE) -print(data) - -library("ggplot2") -library("ggthemes") - -png(file="language_and_duration_by_date.png", width=1024, height=720) - -duration_by_language <- aggregate(duration~language, data=data, FUN=sum) -duration_by_language <- duration_by_language[order(duration_by_language$duration, decreasing=T), ] - -ggplot(data, aes(fill=language, y=duration, x=start_time)) + geom_bar(position="stack", stat="identity") + theme_dark() + - theme(plot.background = element_rect(fill = "#3c3835", color = "black"), panel.background = element_rect("#242221", color="black")) + - labs(x="Date", y="Time coded") + theme(text=element_text(size=20, color="#fbf1c7"), legend.background = element_rect("#4c4541", color="black")) + - theme(axis.text=element_text(color="#b8bb26")) + theme(plot.title=element_text(color="#fb4934")) + - scale_fill_discrete(breaks=duration_by_language$language, labels=paste(duration_by_language$language, ":", duration_by_language$duration, "s")) + - scale_x_date(date_breaks="1 day", date_labels="%b %d") - -duration_by_project_name <- aggregate(duration~project_name, data=data, FUN=sum) -duration_by_project_name <- duration_by_project_name[order(duration_by_project_name$duration, decreasing=T), ] - -png(file="project_and_duration_by_date.png", width=1024, height=720) -ggplot(data, aes(fill=project_name, y=duration, x=start_time)) + geom_bar(position="stack", stat="identity") + theme_dark() + - theme(plot.background = element_rect(fill = "#3c3835", color = "black"), panel.background = element_rect("#242221", color="black")) + - labs(x="Date", y="Time coded") + theme(text=element_text(size=20, color="#fbf1c7"), legend.background = element_rect("#4c4541", color="black")) + - theme(axis.text=element_text(color="#b8bb26")) + theme(plot.title=element_text(color="#fb4934")) + - scale_fill_discrete(breaks=duration_by_project_name$project_name, labels=paste(duration_by_project_name$project_name, ":", duration_by_project_name$duration, "s")) + - scale_x_date(date_breaks="1 day", date_labels="%b %d") - -while (!is.null(dev.list())) - dev.off()