-
Notifications
You must be signed in to change notification settings - Fork 1
Add title and subtitle arguments to g2()
#20
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
Changes from 9 commits
c5cbe33
836b299
75d5d4b
43b1356
5f944a5
f5f066a
c67c188
f206bf9
2ed6e9b
1c4c63a
505ff26
42c2a3b
05c16fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,10 @@ g2_patches_cdn = 'https://cdn.jsdelivr.net/npm/@xiee/utils@v1.14.30/js/g2-patche | |||||||||
| #' (applied to all sides) or a length-4 vector `c(top, right, bottom, left)`; | ||||||||||
| #' use `NA` to skip individual sides. `NULL` (the default) leaves the value | ||||||||||
| #' unset. | ||||||||||
| #' @param title Chart title string, a convenient alternative to piping into | ||||||||||
| #' [title_()] separately. | ||||||||||
| #' @param subtitle Chart subtitle string. Only used when `title` is also | ||||||||||
| #' provided. | ||||||||||
| #' @return A `g2` object (S3 class). | ||||||||||
| #' @import stats utils | ||||||||||
| #' @export | ||||||||||
|
|
@@ -66,9 +70,13 @@ g2_patches_cdn = 'https://cdn.jsdelivr.net/npm/@xiee/utils@v1.14.30/js/g2-patche | |||||||||
| #' # Time series | ||||||||||
| #' g2(sunspot.year) | ||||||||||
| #' g2(EuStockMarkets) | ||||||||||
| #' | ||||||||||
| #' # Title and subtitle | ||||||||||
| #' g2(mtcars, hp ~ mpg, title = 'Motor Trend Cars', subtitle = 'mpg vs hp') | ||||||||||
| g2 = function( | ||||||||||
| data = NULL, ..., width = 640, height = 480, | ||||||||||
| padding = NULL, margin = NULL, inset = NULL | ||||||||||
| padding = NULL, margin = NULL, inset = NULL, | ||||||||||
| title = NULL, subtitle = NULL | ||||||||||
| ) { | ||||||||||
| dots = list(...) | ||||||||||
| has_formula = length(dots) && inherits(dots[[1]], 'formula') | ||||||||||
|
|
@@ -99,7 +107,9 @@ g2 = function( | |||||||||
| theme = NULL, | ||||||||||
| axes = list(), | ||||||||||
| legends = list(), | ||||||||||
| chart_title = NULL, | ||||||||||
| chart_title = if (!is.null(title)) { | ||||||||||
| if (!is.null(subtitle)) list(title = title, subtitle = subtitle) else title | ||||||||||
| }, | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there are so many is.null() tests in this package; can you remove as many of them as possible? in this specific case, you can simply do
Suggested change
and drop the NULLs at some point i don't like this pattern in build_config: there's too much repetition, and even if you remove the !is.null() test, the code still works (assigning NULL to a list item will remove the item)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in |
||||||||||
| facet = facet_from_formula, | ||||||||||
| layout = c( | ||||||||||
| process_layout('padding', padding), | ||||||||||
|
|
||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i've said this many times and written it in copilot instructions: DON'T INCLUDE NEWS FOR v0.1! (please emphasize this again in copilot instructions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in
1c4c63a. Removed the NEWS entry and strengthened the copilot instructions in both the validation steps and conventions sections to explicitly say: do NOT add NEWS entries while the package is at v0.1.