marinebon / infographiqR

R functions for creation of interactive intelligent infographics, ie infographiq
https://marinebon.github.io/infographiqR
MIT License
11 stars 2 forks source link

migrate to authoritative infographiq.js using pkgdown #56

Closed bbest closed 3 years ago

bbest commented 3 years ago

Method

Github Raw is not CORS compliant, eg:

https://raw.githubusercontent.com/marinebon/infographiq/master/inst/js/infographiq.js

Whereas Github Pages is acceptable to load into a different website:

https://marinebon.org/infographiq/infographiq.js

This /inst/js/infographiq.js file is published to the docs/ folder of Github Pages using pkgdown:

pkgdown::build_site()

And the /inst/js/ folder of files is published by having this extra directive in _pkgdown.yml:

template:
  assets: inst/js

TODO

Start versioning infogrpahiq.js, preferably in sync with

#  start creating NEWS.md which shows up as Changelog on website
usethis::use_news()

# at every major/minor/patch version increment update version and copy associated JS
usethis::use_version()
bbest commented 3 years ago

Example R Console sesh w/ @superjai of:

  1. usethis::use_version() to bump up minor version
  2. pkgdown::build_site() to update Github Pages in docs/
> usethis::use_version()
✓ Setting active project to '/Users/bbest/github/infographiq'
There are uncommitted changes and you're about to bump version
Do you want to proceed anyway?

1: Yes
2: Not now
3: No way

Selection: 2
Error: Uncommitted changes. Please commit before continuing.
> usethis::use_version()
Current version is 0.1.3.
Which part to increment? (0 to exit) 

1: major --> 1.0.0
2: minor --> 0.2.0
3: patch --> 0.1.4
4:   dev --> 0.1.3.9000

Selection: 2
✓ Setting Version field in DESCRIPTION to '0.2.0'
✓ Adding new heading to NEWS.md
There are 2 uncommitted files:
* 'DESCRIPTION'
* 'NEWS.md'
Is it ok to commit them?

1: Negative
2: No way
3: I agree

Selection: 3
✓ Adding files
✓ Making a commit with message 'Increment version number'
> pkgdown::build_site()
-- Installing package into temporary library ----------------------------------------
== Building pkgdown site =======================================================
Reading from: '/Users/bbest/github/infographiq'
Writing to:   '/Users/bbest/github/infographiq/docs'
-- Initialising site -----------------------------------------------------------
Copying 'inst/libs/bootstrap-toggle.min.css' to 'bootstrap-toggle.min.css'
Copying 'inst/libs/bootstrap-toggle.min.js' to 'bootstrap-toggle.min.js'
Copying 'inst/libs/d3.v5.min.js' to 'd3.v5.min.js'
Copying 'inst/libs/infographiq.js' to 'infographiq.js'
Copying 'inst/libs/infographiq_v0.1.3.js' to 'infographiq_v0.1.3.js'
Copying 'inst/libs/infographiq_v2019-08-07.js' to 'infographiq_v2019-08-07.js'
Copying 'inst/libs/styles.css' to 'styles.css'
Writing '404.html'
-- Building home ---------------------------------------------------------------
Writing 'authors.html'
Writing 'LICENSE-text.html'
-- Building function reference -------------------------------------------------
Writing 'reference/index.html'
Reading 'man/check_csv_columns.Rd'
Writing 'reference/check_csv_columns.html'
Reading 'man/create_info_site.Rd'
Writing 'reference/create_info_site.html'
Reading 'man/get_plotting_function_brew.Rd'
Writing 'reference/get_plotting_function_brew.html'
Reading 'man/info_svg.Rd'
Writing 'reference/info_svg.html'
Reading 'man/modal_html.Rd'
Writing 'reference/modal_html.html'
Reading 'man/plot_dygraph_timeseries.Rd'
Writing 'reference/plot_dygraph_timeseries.html'
Reading 'man/plot_intertidal_nms.Rd'
Writing 'reference/plot_intertidal_nms.html'
-- Building articles -----------------------------------------------------------
Writing 'articles/index.html'
Reading 'vignettes/captions.Rmd'
Writing 'articles/captions.html'
Reading 'vignettes/plotting_function_call.Rmd'
Writing 'articles/plotting_function_call.html'
Reading 'vignettes/quick-start.Rmd'
Writing 'articles/quick-start.html'
-- Building news ---------------------------------------------------------------
Writing 'news/index.html'
== DONE ========================================================================
Warning message:
Failed to parse example for topic 'get_plotting_function_brew' 
-- Previewing site ------------------------------------------------------------------
Warning message:
In readLines(con) : incomplete final line found on './_pkgdown.yml'
> pkgdown::build_news()
-- Building news --------------------------------------------------------------------
Writing 'news/index.html'
-- Previewing site ------------------------------------------------------------------
superjai commented 3 years ago

Hey @bbest - the florida keys version of the infographiq javascript/css now is quite different than what is found at the nms4r and infographiq repos. I find myself confused about where core infographiq functionality ends and where the specifics for the florida keys begin. A few questions:

  1. Should "Section" be a required column in the input csv/google sheet for the authoritative version?
  2. The modal windows for Florida Keys are generated via columns in the input csv. Should this process be part of the core infographiq process or is it something specific just for the Keys?
  3. Related, the csv structure for nms4r is very different than the csv structure for the Keys.
  4. The infographiq implementation for nms4r has a text toggle button while the implementation for the Keys doesn't.
superjai commented 3 years ago

hey @bbest - improvements to infographiq functionality:

  1. Multiple infographics now possible on same page (two arguments added to infographiq function: svg location, and text location).
  2. Section color is now an argument in the function. There is a default color series, but custom colors are possible too (fed into the function as an array). If the number of sections is greater than the number of custom colors, then the colors repeat. Section color is controlled by two new arguments to the infographiq function (colored_sections and section_colors).

Check out this example.

superjai commented 3 years ago

TO DO

superjai commented 3 years ago

hey @bbest - I have completed the improvements to the infographiq functionality. The lack of highlighting in the svg (which I mentioned in our last conversation) has also been fixed. Check it out here.

You'll notice that I didn't use the bootstrap version of the toggle button for the text on/off and that's because I had great difficulty with getting it to work properly with d3 methods. I instead just used a css-only toggle button.

Infographiq now takes so many potential arguments that a user's manual is definitely needed. On my to-do list.

Before I get to that though, there is a more immediate problem which is that I was unable to use the version of the infographiq javascript and css that I uploaded to the infographiq repo in this folder. Instead, I just used an identical version that I copied over to the fk-esr-info repo here.

I was thinking that I could (maybe) solve my issue with accessing the infographiq version of the javascript/css by running pkgdown, but I was unable to do so. When I run the function pkgdown::build_site() in my local version of the infographiq repo, I get the following output.

> pkgdown::build_site()
-- Installing package into temporary library -------------------------------
== Building pkgdown site =======================================================
Reading from: 'C:/Users/jaira/OneDrive/Documents/infographiq'
Writing to:   'C:/Users/jaira/OneDrive/Documents/infographiq/docs'
-- Initialising site -----------------------------------------------------------
-- Building home ---------------------------------------------------------------
WARNING] Deprecated: markdown_github. Use gfm instead.
-- Building function reference -------------------------------------------------
Error in library(pkg$package, character.only = TRUE) : 
  there is no package called 'infographiq'
Error: callr subprocess failed: there is no package called 'infographiq'
Type .Last.error.trace to see where the error occured
In addition: Warning message:
In utils::install.packages(pkg$src_path, repos = NULL, type = "source",  :
  installation of package ‘C:/Users/jaira/OneDrive/Documents/infographiq’ had non-zero exit status

OK - the problem is clearly that the infographiq package isn't loaded. But, no dice on installing infographiq. Check out what happens when I attempt to install infographiq:

> devtools::install_github("marinebon/infographiq")
Downloading GitHub repo marinebon/infographiq@HEAD
√  checking for file 'C:\Users\jaira\AppData\Local\Temp\Rtmpyq8x6a\remotes189039fa7297\marinebon-infographiq-a027413/DESCRIPTION' ...
-  preparing 'infographiq': (1.7s)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  building 'infographiq_0.2.0.tar.gz'

Installing package into ‘C:/Users/jaira/OneDrive/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package 'infographiq' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'infographiq'
    finding HTML links ... done
    check_csv_columns                       html  
    create_info_site                        html  
    get_plotting_function_brew              html  
    info_svg                                html  
    modal_html                              html  
    plot_dygraph_timeseries                 html  
    plot_intertidal_nms                     html  
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
Error : package 'infographiq' is not installed for 'arch = i386'
Error: loading failed
Execution halted
*** arch - x64
Error : package 'infographiq' is not installed for 'arch = x64'
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/jaira/OneDrive/Documents/R/win-library/4.0/infographiq'
Warning message:
In i.p(...) :
  installation of package ‘C:/Users/jaira/AppData/Local/Temp/Rtmpyq8x6a/file18904daf197a/infographiq_0.2.0.tar.gz’ had non-zero exit status

And here is a possible insight into that not installed for 'arch = x64' problem.

bbest commented 3 years ago

I presume this is a problem with one of the dependent R packages listed in the DESCRIPTION file, so please try to install this one at a time to try finding the offending R package:

Imports: 
    tidyverse,
    brew,
    knitr,
    rmarkdown,
    tools,
    servr,
    dygraphs,
    lubridate,
    stringr,
    xts,
    futile.logger,
    bsplus,
    htmltools,
    r2d3,
    readr

The next question is, can you install infographiq by turning off (ie removing that line) the dependency? So do we really need that package in the first place? Probably not.

superjai commented 3 years ago

hey @bbest. Success! Kind of!

Even after going through your suggestions, I could not get pkgdown to work on my pc (not being able to get past the error that I posted above). Thankfully, there is a Mac in the house and I was able to get pkgdown working just fine there. I am going to move the pc-pkgdown problem into its own issue and then close this issue.

I am using the file structure used by bootstrap. That is, a version folder, which contains js and css folders. Here is the authoritative version 1.0 in the docs folder of the infographiq repo. I included all dependencies in the folders.

My test page showing all of the infographiq possibilities is now running off of this authoritative version of the code. I will next move the Florida Keys infographic, cinms, and nms4r to this version of the code.

bbest commented 3 years ago

Awesome @superjai!

Please be sure to make any changes to these files under inst/libs/ since docs/ gets deleted at the start of running:

pkgdown::build_site()
superjai commented 3 years ago

Yup, that's what I did.

On Mon, Apr 12, 2021 at 9:06 PM Ben Best @.***> wrote:

Awesome @superjai https://github.com/superjai!

Please be sure to make any changes to these files under inst/libs/ https://github.com/marinebon/infographiq/tree/master/inst/libs/ since docs/ https://github.com/marinebon/infographiq/tree/master/docs/ gets deleted at the start of running:

pkgdown::build_site()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/marinebon/infographiq/issues/56#issuecomment-818350591, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANJ3LBTXKPZVXJLU4ALFQLTIOKKRANCNFSM4YDNMTYQ .