Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create plotly.js bundle map programmatically #2336

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

salim-b
Copy link
Contributor

@salim-b salim-b commented Jan 31, 2024

Creates the proper bundleTraceMap list as internal package data object directly from the upstream JS file when plotly.js is updated.

The data is sourced from the file tasks/util/constants.js of the matching plotly.js Git tag via yay::gh_text_file(), which I wrote. The package is not (yet) available on CRAN and thus must be installed via remotes::install_gitlab("rpkg.dev/yay") for the time being. I think this shouldn't be an issue since tools/update_plotlyjs.R is run manually during development and is not intended to be run by users.

This commit adds an updated bundleTraceMap for the currently used plotly.js v2.11.1 to R/sysdata.rda, which now also includes plotly.js' strict bundle, so now plotly::partial_bundle(type = "strict") works as intended.

Creates the proper `bundleTraceMap` list as internal data object directly from the upstream JS file when updating plotly.js.

This commit adds an updated `bundleTraceMap` for the currently used plotly.js v2.11.1 to `R/sysdata.rda`.
@salim-b
Copy link
Contributor Author

salim-b commented Jan 31, 2024

Note that the failing tests are unrelated to this PR, AFAICT.

@@ -23,7 +23,7 @@ Description: Create interactive web graphics from 'ggplot2' graphs and/or a cust
URL: https://plotly-r.com, https://github.com/plotly/plotly.R, https://plotly.com/r/
BugReports: https://github.com/plotly/plotly.R/issues
Depends:
R (>= 3.2.0),
R (>= 3.5),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Contributor Author

@salim-b salim-b Jan 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a requirement for R's latest serialization format (v3), cf. this line. We could stay on the v2 format if it's really important to support R < 3.5.

Comment on lines 74 to 77
yay::gh_text_file(path = "tasks/util/constants.js",
owner = "plotly",
name = "plotly.js",
rev = basename(zip)) |>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer {gh} for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay::gh_text_file() uses gh::gh_gql() under the hood. Unfortunately, the maintainers are not up for inclusion of higher-level GraphQL functions, I've asked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addendum: I've just realized that it's easy to fetch a file from a certain Git tag directly via GitHub URLs. For v2.11.1, the URL is:

https://raw.githubusercontent.com/plotly/plotly.js/v2.11.1/tasks/util/constants.js

So, no need for my yay package here. I'll update the PR.

Copy link
Contributor Author

@salim-b salim-b Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR accordingly and also added package namespace identifiers where missing to make non-base-R dependencies more visible.

This makes non-base-R dependencies clearly apparent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants