marineenergy / apps

shiny apps for marineenergy.app
https://marineenergy.github.io/apps/
MIT License
3 stars 1 forks source link

filter by Technology on Projects Timeline & Map in report-v2 #24

Closed bbest closed 2 years ago

bbest commented 3 years ago

TODO: filter by Technology

image

https://github.com/marineenergy/apps/blob/48a40ed0f1a9dffbd15b69d3b7efac3e3764b78f/report-v2/global.R#L226

which calls:

https://github.com/marineenergy/apps/blob/48a40ed0f1a9dffbd15b69d3b7efac3e3764b78f/scripts/shiny_report.R#L50-L118

and eventually based on ui.R, these get called in the server.R:

https://github.com/marineenergy/apps/blob/48a40ed0f1a9dffbd15b69d3b7efac3e3764b78f/report-v2/server.R#L130-L139

and finally, these are the functions that do the mapping and plotting of the initial outputs:

https://github.com/marineenergy/apps/blob/48a40ed0f1a9dffbd15b69d3b7efac3e3764b78f/scripts/shiny_report.R#L120-L288

To subsequently filter based on Technology Tags of Interactions, I think we want to use a Proxy for both leaflet map and plotly timeline, similar to here:

https://github.com/marineenergy/apps/blob/48a40ed0f1a9dffbd15b69d3b7efac3e3764b78f/report-v2/server.R#L146-L159

bbest commented 3 years ago

Now with @cdobbelaere...

Setup

Copied /share/github/apps_dev to /share/github/apps_cdob and created a branch projects-cdob. Then turned on Shiny app for public viewing (although launching in RStudio is better for debugging):

# change directory
cd /srv/shiny-server

# switch user and do (sudo) symbolically link (ln -s) the github folder to the shiny app URL
sudo ln -s /share/github/apps_cdob/report-v2 report-v2-cdob

Then app served at https://shiny.marineenergy.app/report-v2-cdob/.

Proxy for leaflet Map

leafletProxy("prj_map", data = filteredData()) %>%
      clearShapes() %>%
      addCircles(radius = ~10^mag/10, weight = 1, color = "#777777",
        fillColor = ~pal(mag), fillOpacity = 0.7, popup = ~paste(mag)

Proxy for plotly Timeline

References:

bbest commented 3 years ago

Next step is to similarly proxy leaflet Timeline plot around here:

https://github.com/marineenergy/apps/blob/5715cda496a0144a02b7703dc9fbe0525e82f02e/report-v2/server.R#L165-L168

load_projects()

https://github.com/marineenergy/apps/blob/5715cda496a0144a02b7703dc9fbe0525e82f02e/scripts/shiny_report.R#L74-L142

plot_projects()

https://github.com/marineenergy/apps/blob/5715cda496a0144a02b7703dc9fbe0525e82f02e/scripts/shiny_report.R#L74-L142

Tips:

  1. Note the use of the number of projects per Technology in the y axis given by n_riv, n_tid and n_wav
  2. Maybe create helper functions to generate annotations (horizontal black line) and text (Riverine, Wave, Tidal)
cdobbelaere commented 2 years ago

Plotly projects timeline now updates according to selected technology.

Ex. 1 Initial plot:

Screen Shot 2021-07-09 at 12 17 42 PM

Ex. 2 Filtering by tidal & wave energy:

Screen Shot 2021-07-09 at 12 18 00 PM

Ex. 3 Filtering by riverine & tidal energy:

Screen Shot 2021-07-09 at 12 18 19 PM