cywhale / odb Goto Github PK
View Code? Open in Web Editor NEWMy R works in Ocean Data Bank (ODB), Institute of Oceanography, NTU, Taiwan
Home Page: https://cywhale.github.io/ODB/
My R works in Ocean Data Bank (ODB), Institute of Oceanography, NTU, Taiwan
Home Page: https://cywhale.github.io/ODB/
That's, there're different surveys on the same sampling site, but the BioQuery now always list only one (top one layer on leaflet).
And some other feedback comments:
ToDo List 2018/11/01
Bugs 2018/11/01
Button extension for DataTables js, see
https://datatables.net/extensions/buttons/examples/initialisation/export.html
Similar question such as (not exactly the same for my question):
https://stackoverflow.com/questions/37966718/datatables-export-to-excel-button-is-not-showing
Need call js in order to make buttons (csv, pdf, for table download) of datatables extension work, i.e. loading the following js in order:
jquery.dataTables.min.js
dataTables.buttons.min.js
buttons.bootstrap.min.js
(and other extension e.g., buttons.flash.min.js, jszip.min.js, pdfmake.min.js...)
But one of my tabPanel (BioQuery: https://bio.odb.ntu.edu.tw/query/?bioquery ) also use R package DT that will also load jquery.dataTables.min.js intrinsically in default. If BioQuery is the first tabPanel of shiny, it will cause button extension of datatables js in other tabPanel fail. But if make other tabPanel that use button extension of datatables the first tab, and load a datatable prior to BioQuery (R package DT), all things work.
I wonder if there is another way to keep these js dependency and let me use BioQuery as the first tabPanel with co-work of button extension for datatables js.
My original code to load these js in shiny: (global.R)
library(htmltools)
datatablesDep <- htmltools::htmlDependency("dataTables", "1.10.19", #1.10.16
src = c(href = "https://cdn.datatables.net/1.10.19/"),
script = "js/jquery.dataTables.min.js", stylesheet = "css/jquery.dataTables.min.css"
)
jquerycsvDep <- htmltools::htmlDependency("jquery-csv", "0.8.9", #1.10.16
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/jquery-csv/0.8.9/"),
script = "jquery.csv.min.js"
)
fontawesomeDep <- htmltools::htmlDependency("font-awesome", "4.7.0",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/"),
stylesheet = "css/font-awesome.min.css"
)
but_datatableDep <- htmltools::htmlDependency("buttons.dataTables", "1.5.6",
src = c(href = "https://cdn.datatables.net/buttons/1.5.6/"),
script = "js/dataTables.buttons.min.js", stylesheet = "css/buttons.dataTables.min.css"
)
but_bootstrapDep <- htmltools::htmlDependency("buttons.bootstrap", "1.5.6",
src = c(href = "https://cdn.datatables.net/buttons/1.5.6/"),
script = "js/buttons.bootstrap.min.js", stylesheet = "css/buttons.bootstrap.min.css"
)
but_dt_flashDep <- htmltools::htmlDependency("buttons_flash", "1.5.6",
src = c(href = "https://cdn.datatables.net/buttons/1.5.6/"),
script = "js/buttons.flash.min.js"
)
but_js_zipDep <- htmltools::htmlDependency("jszip", "3.1.3",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/"),
script = "jszip.min.js"
)
but_pdfmakeDep <- htmltools::htmlDependency("pdfmake", "0.1.53",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/"),
script = "pdfmake.min.js"
)
but_vfs_fontsDep <- htmltools::htmlDependency("vfs_fonts", "0.1.53",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/"),
script = "vfs_fonts.js"
)
but_html5Dep <- htmltools::htmlDependency("buttons_html5", "1.5.6",
src = c(href = "https://cdn.datatables.net/buttons/1.5.6/"),
script = "js/buttons.html5.min.js"
)
but_printDep <- htmltools::htmlDependency("buttons_print", "1.5.6",
src = c(href = "https://cdn.datatables.net/buttons/1.5.6/"),
script = "js/buttons.print.min.js"
)
in server.R
library(DT)
in ui.R
jqueryDep <- htmltools::htmlDependency("jquery", "1.12.4",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/"),
script = "jquery.min.js"
)
jqueryuiDep <- htmltools::htmlDependency("jquery-ui", "1.12.1",
src = c(href = "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/"),
script = "jquery-ui.min.js"
)
shinyUI(function(req) { tagList(
jqueryDep,
jqueryuiDep, ...
tabPanel("Open API", #div(class='hiddenx', uiOutput('jsblk_ui')),
datatablesDep,jquerycsvDep,but_datatableDep,but_bootstrapDep,
but_dt_flashDep,but_js_zipDep,but_pdfmakeDep,but_vfs_fontsDep,
but_html5Dep,but_printDep,
htmlTemplate("www/ocpu_api.html")
),
tabPanel("BioQuery",...)
)
})
Still try to find some better solutions..
See detail here:
opencpu/opencpu#342
and files in my repos
Now I still have no idea the bug is in me, or something wrong in using opencpu.js. The RDA plot is correct when using curl https://bio.odb.ntu.edu.tw/api/bioquery -d return_type="community_rda_plot", ....
[update]
NOT exactly this problem, bugs of this issue remains, keep debugging...
Seems leaflet 2.0.2 version do not have this problem, but 2.0.3 has.
[old trials]
This bug occurred when loading cached leaflet map by using R.cache::loadCache(key)
Error message is:
Error in value[[3L]]: Couldn't normalize path in
addResourcePath
, with arguments:prefix
= 'leaflet-providers-1.9.0';directoryPath
At beginning it seems a problem caused by R.cache saveCache error when use three-dots argument (ellipsis)
In shiny, use R.cache to memoise cached data, such as
https://github.com/cywhale/ODB/tree/master/shiny_memoised_cache
BUT when use leaflet.providers, it will pass 'prefix' arguments when passing ... in memoised function, then I guess it may cause aboving error.
Modified functions memFx() in
https://github.com/cywhale/ODB/blob/master/shiny_memoised_cache/app.R
data <- FUN(...)
by matching function call arguments like this
ll <- list(...)
args <- formals(FUN)
argx <- ll[names(ll) %in% names(args)]
data <- do.call(FUN, argx)
I'll test more cases to make sure it works.
Shiny app url https://bio.odb.ntu.edu.tw/query
Sometimes, even all cpu cores not occupied, the user operations (such as click a button, span the advanced analyze mode window, etc) will delay behaved after seconds, or after several user operations. After suddenly recovery, these undone operations will be served.
Difficult to reproduce the unregular intrasession delayed operations.
Suspect that the causes may due to Shiny + promises + future package introduce unwanted intrasession delay? Not correctly return processing state back after future-object resolved?.
Comments about the possible causes for this issue needed.
A small clip demo how asyn feature provided by Rshiny promises and r-future package work behind BioQuery, ODB
https://twitter.com/bramasolo/status/1004242453400965120
Reference: Async process blocks shiny app within "user session"
rstudio/promises#23
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.