Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions 06-interactive.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
library(plotly)
```

## Add Buttons
## Add Buttons and Range Slider

We put the volatility of USDC and USDT into one plot because the volatility of the two cryptos have similar trends. In this interactive plot, we create three buttons that includes three options: showing the volatility of USDC, showing the volatility of USDT, and showing both cryptos.
In this interactive plot, we also add the range slider, so if people want to observe the plot of volatility in a specific range, the can move the buttons which are in the two side of the range slider.


```{r}
##set the dataframe
df_USDC<-df.crypto[df.crypto$cryptocurrency =="USDC",]
df_USDT<-df.crypto[df.crypto$cryptocurrency =="USDT",]
df_J_I<-data.frame(cbind(df_USDT$Date,df_USDT$volatility,
df_USDC$volatility))
df_J_I<-data.frame(cbind(format(as.Date(df_USDC$Date),"%Y/%m/%d"),
df_USDT$volatility,df_USDC$volatility))
colnames(df_J_I) <- c("Date","USDT_vol","USDC_vol")
fig_J_I <- plot_ly(df_J_I, type = "scatter" , mode = "lines")
fig_J_I<- fig_J_I %>% add_lines(x=~Date, y=~USDT_vol, name="USDT",
Expand Down Expand Up @@ -46,17 +48,8 @@ fig_J_I_update <- fig_J_I %>% layout(title = "Volatility", showlegend=FALSE,
yaxis=list(title="Volatility"),
updatemenus=update_trace)

fig_J_I_update
```

## Range Slider

In this interactive plot, we add the range slider, so if people want to observe the plot of volatility in a specific range, the can move the buttons which are in the two side of the range slider.

```{r}
fig_J_I_range<-fig_J_I%>%
fig_J_I_update%>%
layout(xaxis = list(rangeslider = list(visible = T)))
fig_J_I_range
```


Expand Down