-
Notifications
You must be signed in to change notification settings - Fork 1
/
dashboard_sub.Rmd
106 lines (83 loc) · 4.01 KB
/
dashboard_sub.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
`r if (heroes %in% tank_heroes) {
paste0('#', stri_trans_totitle(heroes), '{data-navmenu="Tank"}')
} else {if (heroes %in% healer_heroes) {paste0('#', stri_trans_totitle(heroes), '{data-navmenu="Support"}')
} else {paste0('#', stri_trans_totitle(heroes),'{data-navmenu="Damage"}')}}`
Row {data-height=550,data-width=450}
-----------------------------------------------------------------------
`r paste("###",stri_trans_totitle(heroes),": K/D Average Per 10 Min (Play Time >", round(play_time_min/60),"Min)")`
```{r}
sub1 <- subpage_data$data()[Stats_name=="eliminations_avg_per_1m"]
sub2 <- subpage_data$data()[Stats_name=="deaths_avg_per_1m"]
setkey(sub1,Player)
setkey(sub2,Player)
sub12 <- sub2[sub1]
share12 <- SharedData$new(sub12,~Player,group="hero_stats_subset")
sp1 <- plot_ly(share12, x = ~Value, y = ~i.Value, color = ~Team, colors=color_str,
hoverinfo = 'text',
text = ~paste('</br> ', Player,
'-', Team,
'</br> Elimination: ', round(i.Value,2),
'</br> Deaths: ', round(Value,2),
'</br> K/D: ', round(i.Value/Value,2),
'( Rank ', frankv(-i.Value/Value),')'
)) %>%
add_markers() %>%
add_text(text=~Player,textposition = "bottom right") %>%
config(displayModeBar = F) %>%
layout(xaxis = list(title="Deaths/10 Min"), yaxis = list(title="Eliminations/10 Min"),showlegend = FALSE)%>%
highlight(opacityDim=1,off="plotly_doubleclick",
selected = attrs_selected(marker=list(size=10,line = list(
color = "#999",
width = 3,
opancity = 0.1
))))
sp1
```
`r paste("###",stri_trans_totitle(heroes),": Player Overall Statistics (Play Time >", round(play_time_min/60),"Min)")`
```{r}
library(DT)
sub_datetable <- dcast(subpage_data$data()
[,c("Player","Team","Stats_name_formatted","Value")],
Player+Team~str_split(Stats_name_formatted,pattern = "/",simplify=T)[,1],value.var="Value")[,"K/D":=Eliminations/Deaths]
if (!heroes %in% healer_heroes) sub_datetable[,Healing:=NULL]
sub_DT <- SharedData$new(sub_datetable
,~Player,group="hero_stats_subset")
dt1 <- datatable(sub_DT,
rownames = FALSE,
class = 'compact order-column hover ',
extensions = 'Scroller',
options=list(dom='t',scrollX=F,
deferRender=T,
scrollY=500,
scroller=T,
autoWidth = TRUE,
initComplete = JS(
"function(settings, json) {",
"$('body').css({'font-family': 'Arial',
'font-size': '15px'});",
"}")
))%>%
formatRound(c("Deaths","Eliminations","Final Blows","Ultimates Earned","K/D"),2)
if (heroes %in% healer_heroes) {dt1 %>% formatCurrency(c("Hero Damage","Healing"),currency="",digits=0)
} else { dt1 %>% formatCurrency(c("Hero Damage"),currency="",digits=0)}
```
Row {data-height=450}
-----------------------------------------------------------------------
`r paste("###",stri_trans_totitle(heroes),": Stats Average Per 10 Min (Play Time >", round(play_time_min/60),"Min)")`
```{r fig.width=20,out.width = "100%",out.height="100%"}
p <- ggplot(subpage_data,
aes(x = Rank, y = Value, fill = Team))+
geom_col()+
scale_y_continuous(expand = c(0,0),label=comma)+
scale_x_discrete(labels=subpage_data$data()[, setNames(as.character(Player), Rank)])+
xlab("")+ylab("")+
facet_wrap(~Stats_name_formatted,scales="free",drop=T,nrow=1)+
scale_fill_manual(values=color_str)+
theme_minimal()+
theme(axis.text.x = element_text(angle = 45, hjust = 1,size=7), legend.title = element_blank(),
axis.text.y=element_text(size = 8),
panel.grid.major.x=element_blank(),panel.grid.minor=element_blank(),
panel.spacing.x = unit(0, "lines"))
sp <- ggplotly(p) %>% config(displayModeBar = F) %>% layout(autosize = T)
sp
```