Conversation
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/5209206a-199c-42cd-a4ed-9fd9709eca79 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
yihui-bot
left a comment
There was a problem hiding this comment.
i wonder if we can do it differently, i.e., is it possible to modify the G2 object in JS? e.g., for the lack of support for column-major data, i wrote this script to support it: https://github.com/yihui/lite.js/blob/main/js/g2-column.js similarly i wish i can modify some of G2's default settings via JS, so we don't need to carry these settings on every single plot produced from gglite
that said, i think it's still a good idea to have a way to customize the theme globally via an R function (similar to R's par() function); please provide that function but it shouldn't do anything by default; i still prefer the default to be changed via a JS method if possible
the 20% increase doesn't seem to be enough; try a slightly larger percent
btw, i also want to change the default point shape to a solid point instead of a empty circle; see if that's possible
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/e37544b3-7851-472d-8617-fdb37517dde0 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
…R spec
- G2.register('theme:classic', ...) doesn't actually override theme factories
- Move theme defaults (font sizes, grid opacity) to R-side .theme_defaults
- build_config() now always applies base theme, merging g2_defaults() and
per-chart theme_() on top
- Remove broken inst/js/g2-defaults.js
- Keep mark_point() solid shape default, adapted to mark_() naming
- Keep g2_defaults() function for user global overrides
- Adapt all tests to main's API naming (theme_(), axis_(), etc.)
Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
yihui-bot
left a comment
There was a problem hiding this comment.
i've done the patches in JS; simplify R code now
| opts = list(...) | ||
| if (is.null(opts$style)) { | ||
| opts$style = list(shape = 'point') | ||
| } else if (is.null(opts$style$shape)) { | ||
| opts$style = modifyList(list(shape = 'point'), opts$style) | ||
| } |
There was a problem hiding this comment.
your code is unnecessarily complicated, just do
| opts = list(...) | |
| if (is.null(opts$style)) { | |
| opts$style = list(shape = 'point') | |
| } else if (is.null(opts$style$shape)) { | |
| opts$style = modifyList(list(shape = 'point'), opts$style) | |
| } | |
| opts = modifyList(list(style = list(shape = 'point')), list(...)) |
There was a problem hiding this comment.
Done in 1b24683. Simplified to opts = modifyList(list(style = list(shape = 'point')), list(...)).
|
|
||
| # Base theme defaults: ~25% larger fonts and more visible grid lines than G2's | ||
| # built-in 12px / 0.1 opacity defaults. | ||
| .theme_defaults = list( |
There was a problem hiding this comment.
get rid of this; i've patched G2 in JS myself; please use https://cdn.jsdelivr.net/npm/@xiee/utils/js/g2-patches.min.js instead of https://cdn.jsdelivr.net/npm/@xiee/utils/js/g2-column.min.js in this package
There was a problem hiding this comment.
Done in 1b24683. Removed .theme_defaults and switched CDN to g2-patches.min.js.
| #' old = g2_defaults(axis = list(labelFontSize = 18)) | ||
| #' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() | ||
| #' g2_defaults(old) # restore previous defaults | ||
| g2_defaults = function(...) { |
There was a problem hiding this comment.
get rid of this function, but keep the support for options('gglite.theme'); document this option on the help page of theme_ instead, and provide a few more keys in the theme list to show, for example, how to set the default title font size, axis grid line opacity, etc
There was a problem hiding this comment.
Done in 1b24683. Removed g2_defaults(), kept options('gglite.theme') support in build_config(), and documented the option on theme_()'s help page with examples for title font size, axis grid opacity, and legend label size.
…ches.min.js CDN, simplify mark_point()
- Remove .theme_defaults from R/render.R (JS patches handle defaults now)
- Remove g2_defaults() function; keep options('gglite.theme') support
- Document gglite.theme option on theme_() help page with examples
- Use g2-patches.min.js CDN instead of g2-column.min.js
- Simplify mark_point() with modifyList as suggested
- Update tests accordingly
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/138a6388-abcc-48a5-b429-01b53ab03171
Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Done in |
Default theme patches (larger fonts, visible grid lines, solid point shape) are now handled externally via
g2-patches.min.js. R code is simplified to only carry per-chart and user-global theme overrides.Changes Made
g2-column.min.jstog2-patches.min.js, which handles both column-major data conversion and G2 theme patchesmark_point()defaults to solid'point'shape instead of hollow circleoptions(gglite.theme = list(...))to customize theme globally; documented ontheme_()help page with examples for title font size, axis grid opacity, legend label size, etc.g2_defaults(): Replaced by the simpleroptions('gglite.theme')mechanism.theme_defaults: No longer needed since JS patches handle base defaults externally