Add title and subtitle arguments to g2()#20
Conversation
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
…lot() Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
… convention) Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
…yplot Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
… gg() test Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
yihui-bot
left a comment
There was a problem hiding this comment.
drop the gg alias; it doesn't make any sense: g2 only has two chars, and gg also has two chars; no keystrokes will be saved
change main to title, and sub to subtitle
the by argument is too trivial; users can just specify color = 'Species'
formula | for color also doesn't make much sense; uses can type color = variable name
i don't like alpha or palette; drop them
in the end, only keep title/subtitle; nothing else is good
…t per review Agent-Logs-Url: https://github.com/yihui/gglite/sessions/2d28c2bc-b9d1-4f63-b367-28a0353f740a Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Done in |
title and subtitle arguments to g2()
| chart_title = if (!is.null(title)) { | ||
| if (!is.null(subtitle)) list(title = title, subtitle = subtitle) else title | ||
| }, |
There was a problem hiding this comment.
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
| chart_title = if (!is.null(title)) { | |
| if (!is.null(subtitle)) list(title = title, subtitle = subtitle) else title | |
| }, | |
| chart_title = list(title = title, subtitle = subtitle), |
and drop the NULLs at some point
i don't like this pattern in build_config:
if (!is.null(chart$chart_title)) config$title = chart$chart_title
if (!is.null(chart$tooltip_config)) config$tooltip = chart$tooltip_config
if (!is.null(chart$sliders)) config$slider = chart$sliders
if (!is.null(chart$scrollbars)) config$scrollbar = chart$scrollbars
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)
There was a problem hiding this comment.
Done in 1c4c63a. Simplified chart_title to dropNulls(list(title = title, subtitle = subtitle)). Removed the is.null() checks for tooltip_config, sliders, and scrollbars in build_config() — now just direct assignments.
|
|
||
| - Added `title` and `subtitle` arguments to `g2()` for setting the chart title | ||
| and subtitle directly, as a convenient alternative to piping into `title_()`. |
There was a problem hiding this comment.
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.
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.
…EWS for v0.1 Agent-Logs-Url: https://github.com/yihui/gglite/sessions/1f1ea7ca-8cdb-4cc9-9f6f-5bfbe65344d2 Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
yihui-bot
left a comment
There was a problem hiding this comment.
also mention this way of specifying title/subtitle in the titles-tooltips.Rmd example
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/c1c083a1-cad5-4057-a1c8-81d37f9f548b Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Done in |
chart_titleing2()todropNulls(list(title = title, subtitle = subtitle))is.null()checks inbuild_config()for tooltip/slider/scrollbartitle/subtitleg2()argument examples toexamples/titles-tooltips.Rmd