---
title: "Flex Dashboards"
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
theme: yeti
source_code: embed
---
```{r setup, include=FALSE}
# Importing libraries
library(flexdashboard)
library(tidyverse)
library(highcharter)
library(gt)
library(htmltools)
library(viridis)
library(DT)
```
```{r, include = FALSE}
# Importing data
gen4 <- read.csv('Kpop 4th gen Sales.csv')
gen4 <- subset(gen4, select = -c(date,country))
gen4$sales <- as.numeric(gen4$sales)
gen4 %>%
group_by(Artist, title) %>%
summarise(across(c(sales, peak_chart), sum))
```
Table {data-orientation=rows}
=======================================================================
### Table {data-height=520}
```{r}
# This is going to be a datatable
gen4x <- gen4 %>%
filter(sales >= 100000) %>%
arrange(desc(sales)) %>%
select(Artist, title, sales ,peak_chart)
datatable(gen4x,
options=list(scrollX=TRUE),
caption = htmltools::tags$caption(
style = 'caption-side: bottom; text-align: center;',
'Table: ', htmltools::em('Kpop 4th Gen Group Which Albums sales exceed 100K')
))
```
Bar-chart {data-orientation=columns}
=======================================================================
## Row {.tabset .tabset-fade data-height=640}
-----------------------------------------------------------------------
### Vertical {data-width=1000}
```{r fig.height=5}
# Colors
custom_colors <- viridis::plasma(n = 10)
# Most popular authors by reviews
gen4 %>%
group_by(Artist) %>%
summarise(sales = sum(sales)) %>%
arrange(desc(sales)) %>%
head(10) %>%
hchart('column', hcaes(x = Artist, y = sales ,color = custom_colors)) %>% hc_add_theme(hc_theme_google()) %>%
hc_tooltip(pointFormat = '<b>Number of Sales: </b> {point.y} <br>') %>%
hc_title(text = 'Top 10 Most Popular 4th Gen Kpop Group',
style = list(fontSize = '25px', fontWeight = 'bold')) %>%
hc_subtitle(text = 'By Total Album Sold Worldwide',
style = list(fontSize = '16px')) %>%
hc_credits(enabled = TRUE, text = '@stroberi')
```
### Horizontal {data-width=1000}
```{r fig.height=5}
# Colors
custom_colors <- viridis::magma(n = 20)
gen4 %>%
arrange(desc(peak_chart)) %>%
head(20) %>%
hchart('bar', hcaes(x = title, y = peak_chart, color = custom_colors)) %>%
hc_add_theme(hc_theme_google()) %>%
hc_tooltip(pointFormat = '<b>Number of Weeks on Chart Peak: </b> {point.y} <br>') %>%
hc_title(text = "Top 20 Most Popular 4th Gen Kpop Album ",
style = list(fontSize = '30px', fontWeight = 'bold')) %>%
hc_subtitle(text = "by Weeks on Chart's Peak",
style = list(fontSize = '16px')) %>%
hc_credits(enabled = TRUE, text = 'stroberi')
```