-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathtm_chart.R
More file actions
161 lines (138 loc) · 4.04 KB
/
tm_chart.R
File metadata and controls
161 lines (138 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#' Legend charts
#'
#' Legend charts are small charts that are added to the map, usually in addition to legends.
#'
#' Note that these charts are different from charts drawn inside the map. Those are called glyphs (to be implemented).
#'
#' @param breaks The breaks of the bins (for histograms)
#' @param plot.axis.x,plot.axis.y Should the x axis and y axis be plot?
#' @param extra.ggplot2 Extra ggplot2 code
#' @inheritParams tm_title
#' @example examples/tm_chart.R
#' @seealso \href{https://r-tmap.github.io/tmap/articles/basics_charts}{Vignette about charts}
#' @name tm_chart
#' @export
tm_chart_histogram = function(breaks,
plot.axis.x,
plot.axis.y,
extra.ggplot2,
position,
group_id,
width,
height,
stack,
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "histogram"
args$summary = "binned"
structure(args, class = c("tm_chart_histogram", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_bar = function(plot.axis.x,
plot.axis.y,
extra.ggplot2,
position,
group_id,
width,
height,
stack,
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "bar"
args$summary = "binned"
structure(args, class = c("tm_chart_bar", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_donut = function(position,
group_id,
width,
height,
stack,
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "donut"
args$summary = "binned"
structure(args, class = c("tm_chart_donut", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_violin = function(position,
group_id,
width,
height,
stack,
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "violin"
args$summary = "raw_nna"
structure(args, class = c("tm_chart_violin", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_box = function(position,
group_id,
width,
height,
stack,
z,
...) {
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "box"
args$summary = "raw_nna"
structure(args, class = c("tm_chart_box", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_none = function() {
structure(list(show = FALSE, group_id = NA_character_, z = NA_integer_, summary = "none"), class = c("tm_chart_none", "tm_chart", "tm_component", "list"))
}
#' @rdname tm_chart
#' @export
tm_chart_heatmap = function(position,
group_id,
width,
height,
stack,
z,
...){
args = lapply(as.list(rlang::call_match()[-1]), eval, envir = parent.frame())
args = warning_group_args(args)
args$z = args$z %||% NA_integer_
args$group_id = args$group_id %||% NA_character_
args$group_type = "tm_chart"
args$show = TRUE
args$type = "heatmap"
args$summary = "binned2D"
structure(args, class = c("tm_chart_heatmap", "tm_chart", "tm_component", "list"))
}