cmu-delphi / forecast-eval

delphi.cmu.edu/forecast-eval
MIT License
5 stars 2 forks source link

Consider making `plotly` plot directly instead of converting from `ggplot` plot #276

Open nmdefries opened 1 year ago

nmdefries commented 1 year ago

There's some indication that plotly plots are faster to generate than making a ggplot2 plot and converting to plotly. Since plot creation and rendering is a slow part of the dashboard, meaning this switch could be a good way to provide overall speedups to the dashboard.

Most of the work has already been done on the ndefries/use-plotly-directly branch. Remaining tasks to match behavior of current dashboard:

Horizon labels

str(finalPlot$x$layout$annotations, max.level = 2) $ :List of 12 ..$ text : chr "Horizon: 2 Week(s)" ..$ x : num 0.5 ..$ y : num 0.486 ..$ showarrow: logi FALSE ..$ ax : num 0 ..$ ay : num 0 ..$ font :List of 3 ..$ xref : chr "paper" ..$ yref : chr "paper" ..$ textangle: num 0 ..$ xanchor : chr "center" ..$ yanchor : chr "bottom"


- Add "drag to zoom" text as separate annotation? might scale better with page size changes
- [Add horizontal reference line](https://github.com/cmu-delphi/forecast-eval/blob/d0cec65fdc1d5654496d8b10982e51300ae79cb0/app/server.R#L459) for coverage plots
- Setting x-axis limits depending on the as-of date selection and whether forecast values are displayed on the truth plot. `plotly` doesn't [let an axis limit float if passed an `NA`](https://github.com/cmu-delphi/forecast-eval/blob/381814483b6aa6a7e7f0b1bc97766d83561c65b7/app/server.R#L433-L439), so we'd probably need to define a separate function to calculate min/max x limits based on data range.
- Make y-axis ranges match across subplots