marinebon / p2p

Pole to Pole website
https://marinebon.github.io/p2p
3 stars 1 forks source link

show graph inside popups? #6

Closed 7yl4r closed 5 years ago

7yl4r commented 5 years ago

On the index page @eqmh would like to get a timeseries plot into the popups. Simplest way to accomplish that is going to be using an iframe I think. Here is a S.O. Q/A on that.

eqmh commented 5 years ago

Not sure if this is overkilled but there is cool stuff we could pull from this Shiny app.

eqmh commented 5 years ago

OK, I just found a Shiny app that @bbest created a while back to show phyto pigment data collected in the MBON cruises. This will do the job! The only thing to do here is to replace the pie charts with line plots and perhaps add a data download button.

7yl4r commented 5 years ago

:thinking: Ooh that does look nice.

Unfortunately shiny app code may not work here since it runs on a shiny server and this is set up to build as a static page. I don't know of a way to generate shiny code into a static webpage, but it might exist.

eqmh commented 5 years ago

I have been trying this code in the Data_in_situ.Rmd:

library(shiny)
runGitHub("marinebon/hplc-vis", username = getOption("eqmh"), ref = "master",
launch.browser = getOption("shiny.launch.browser", interactive()))

This runs OK in the command line but when I knit the Rmd it doesn't render the app:

screen shot 2018-12-25 at 10 35 11 am
7yl4r commented 5 years ago

That is about what I would expect. Shiny is a separate "stack" from the knitr static server stack being used in this project.

Shiny runs a (dynamic) server and client application that connects to the server to execute R code at runtime (ie when you open the page). The code in this repo must all build before runtime into "static" html/css/js to be served on github's static server.

In short: shiny needs a shiny-server, and that doesn't jive with the build process here. Ben might know of something I don't, but it's a hard problem to work around.

7yl4r commented 5 years ago

See the above linked commit on the mapplots branch of one way to use iframes. I added a popup_url column to sites.csv and then modified index.Rmd to use that column:

 sites$html <- with(
     sites, paste("<iframe src='", popup_url, "'></iframe>", sep="")
 )

I set all popup_url values to a test url:

image

Sizing can be tricky, but in theory anything could go there. So I guess now we need something that generates the view for each site as a standalone html page?

eqmh commented 5 years ago

Nice, @7yl4r ! I will grab the temp data from our sensors as a start.

bbest commented 5 years ago

Hi @eqmh and @7yl4r,

Here's a few more links:

Look forward to chatting about overall strategy further with you both. For instance,

  1. @eqmh can you please send some sample data from your Android robolimpet app to electric.blue.data@gmail.com?

  2. Then I can process the data using this script: http://marinebon.github.io/thermal-data.

  3. And publish time series into a map popup a la this issue onto p2p website.

This is one aspect of larger vision to integrate biological data in the field with satellite and in situ environmental data.

I'll be joining you both in Miami Jan 15-16, flying to TPA ~4pm Thu Jan 17, leaving TPA ~noon Fri Jan 25 so we have a week+ to dig in.

7yl4r commented 5 years ago

@bbest thanks for the links!

Is this automated process through the email?

7yl4r commented 5 years ago

@eqmh and I put an hour into this today and connected up the thermaldata dygraph to the popup. Unfortunately the dygraph html doesn't do so well in the little box:

image

bbest commented 5 years ago

Well done guys! That's a great accomplishment getting the htmlwidget to even appear in the popup. The sparkline widget is better suite for small space like the example above. Then in the popup you could include a link to the individual station page that has the full dygraph time series.

You could generate these station pages using a parameterized Rmarkdown report and flexdashboard, similar to Ship Report Card: CARNIVAL INSPIRATION:

image

See repo ecoquants/ship-cards:

bbest commented 5 years ago

Hi @eqmh & @7yl4r ,

I updated the MBON P2P home page map to have a popup:

image

that links to a sampling site page with SST extracted from ERDDAP in the form of:

  1. Map most recent SST, postage stamp size (10x10):

    image

  2. Timeseries plot of entire period available (2004 to now):

    image

    These values get cached into data/sst and when the site is rendered any missing values since last time are fetched and included.

  3. Photos of the site for any provided with URLs in data/site_photos.csv:

    image

More details on the mechanics are included in the README.

A few things that come to mind as next step improvements:

  1. Indicate habitats sampled on home map and site pages:
    • rocky shore
    • sandy beach
  2. Add map & table to pages:
  3. Photo carousel indicators don't seem to work, but wait a couple seconds and next one show.
  4. Resize photo carousel so same width as map and timeseries.
  5. Use global SST layer on site map so not just postage stamp (but see issues outlined in ERDDAP issue on #24).