Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Suggests:
knitr,
shiny,
testit
VignetteBuilder: litedown
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ S3method(record_print,g2)
export(animate)
export(axis_of)
export(chart_html)
export(coord_helix)
export(coord_parallel)
export(coord_polar)
export(coord_radar)
export(coord_radial)
export(coord_theta)
export(coord_transpose)
export(coordinate)
export(encode)
Expand Down Expand Up @@ -56,6 +62,11 @@ export(scale_of)
export(scrollbar_of)
export(slider_of)
export(style_mark)
export(theme_academy)
export(theme_classic)
export(theme_classicDark)
export(theme_dark)
export(theme_light)
export(theme_of)
export(title_of)
export(tooltip_of)
Expand Down
65 changes: 65 additions & 0 deletions R/coordinate.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,68 @@ coord_transpose = function(chart) {
)
chart
}

#' Polar Coordinate System
#'
#' Shortcut for `coordinate(chart, 'polar', ...)`.
#'
#' @inheritParams coordinate
#' @export
#' @examples
#' g2(data.frame(x = c('A', 'B', 'C'), y = c(3, 7, 2)),
#' x = 'x', y = 'y', color = 'x') |>
#' mark_interval() |> coord_polar()
coord_polar = function(chart, ...) coordinate(chart, 'polar', ...)

#' Theta Coordinate System
#'
#' Shortcut for `coordinate(chart, 'theta', ...)`. Used for pie and donut
#' charts.
#'
#' @inheritParams coordinate
#' @export
#' @examples
#' g2(data.frame(x = c('A', 'B', 'C'), y = c(3, 7, 2)),
#' x = 'x', y = 'y', color = 'x') |>
#' mark_interval() |> transform_of('stackY') |>
#' coord_theta(innerRadius = 0.5)
coord_theta = function(chart, ...) coordinate(chart, 'theta', ...)

#' Radial Coordinate System
#'
#' Shortcut for `coordinate(chart, 'radial', ...)`. Suitable for radial bar
#' charts.
#'
#' @inheritParams coordinate
#' @export
#' @examples
#' g2(data.frame(x = c('A', 'B', 'C'), y = c(3, 7, 2)),
#' x = 'x', y = 'y', color = 'x') |>
#' mark_interval() |> coord_radial()
coord_radial = function(chart, ...) coordinate(chart, 'radial', ...)

#' Radar Coordinate System
#'
#' Shortcut for `coordinate(chart, 'radar', ...)`. Used with `position`
#' encoding for radar (spider) charts.
#'
#' @inheritParams coordinate
#' @export
coord_radar = function(chart, ...) coordinate(chart, 'radar', ...)

#' Helix Coordinate System
#'
#' Shortcut for `coordinate(chart, 'helix', ...)`.
#'
#' @inheritParams coordinate
#' @export
coord_helix = function(chart, ...) coordinate(chart, 'helix', ...)

#' Parallel Coordinate System
#'
#' Shortcut for `coordinate(chart, 'parallel', ...)`. Used with `position`
#' encoding for parallel coordinate plots.
#'
#' @inheritParams coordinate
#' @export
coord_parallel = function(chart, ...) coordinate(chart, 'parallel', ...)
50 changes: 50 additions & 0 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,53 @@ theme_of = function(chart, type, ...) {
}
chart
}

#' Classic Theme
#'
#' Shortcut for `theme_of(chart, 'classic', ...)`. This is the default theme.
#'
#' @inheritParams theme_of
#' @export
#' @examples
#' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() |> theme_classic()
theme_classic = function(chart, ...) theme_of(chart, 'classic', ...)

#' Classic Dark Theme
#'
#' Shortcut for `theme_of(chart, 'classicDark', ...)`.
#'
#' @inheritParams theme_of
#' @export
#' @examples
#' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() |> theme_classicDark()
theme_classicDark = function(chart, ...) theme_of(chart, 'classicDark', ...)

#' Light Theme
#'
#' Shortcut for `theme_of(chart, 'light', ...)`.
#'
#' @inheritParams theme_of
#' @export
#' @examples
#' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() |> theme_light()
theme_light = function(chart, ...) theme_of(chart, 'light', ...)

#' Dark Theme
#'
#' Shortcut for `theme_of(chart, 'dark', ...)`.
#'
#' @inheritParams theme_of
#' @export
#' @examples
#' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() |> theme_dark()
theme_dark = function(chart, ...) theme_of(chart, 'dark', ...)

#' Academy Theme
#'
#' Shortcut for `theme_of(chart, 'academy', ...)`.
#'
#' @inheritParams theme_of
#' @export
#' @examples
#' g2(mtcars, x = 'mpg', y = 'hp') |> mark_point() |> theme_academy()
theme_academy = function(chart, ...) theme_of(chart, 'academy', ...)
17 changes: 17 additions & 0 deletions man/coord_helix.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/coord_parallel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions man/coord_polar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/coord_radar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/coord_radial.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/coord_theta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/theme_academy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/theme_classic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/theme_classicDark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/theme_dark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions man/theme_light.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading