blob: 7cafeb21b37af9c14ce985a83a429257c8397268 [file] [log] [blame]
Marc Kupietzcd7acbd2020-12-10 14:02:52 +01001#' Dark IDS theme for \link[highcharter]{highcharter}
2#'
3#' @param fontFamily font family
4#' @param fontSize default font size
5#' @param textColor default text color
6#' @param lowContrastColor color with low contrast to background
7#' @param highContrastColor color with high contrast to background
8#' @param palette array of colors to be used for different series
9#' @param backgroundColor background color
10#' @param titleColor color of the title text
11#' @param subtitleColor color of the subtitle text
12#' @param gridLineColor color of grid lines
13#' @param axisLabelColor color of the axis labels
14#' @param axisLineColor color of the axis lines
15#' @param minorGridLineColor color of minor grid lines
16#' @param tickColor color of axis ticks
17#' @param axisTitleColor color of axis titles
18#' @param tooltipBackgroundColor background color for tool tips
19#' @param tooltipColor foreground color for tool tips
20#' @param dataLabelColor color of data point labels
21#' @param boxplotFillColor color for box plot fills
22#' @param candlestickColor color the candle stick part of error bars
23#' @param errorbarColor error bar color
24#' @param legendColor series legend label color
25#' @param legendHoverColor mouse over series legend label color
26#' @param legendHiddenColor hidden series legend label color
27#' @param creditsColor color of the credits
28#' @param burgerMenuBackground burger menu background color
29#' @param ... named arguments to modify the theme
30#'
31#' @importFrom magrittr %>%
32#' @import tidyverse
33#' @import highcharter
34#'
35#' @examples
36#' library(tidyverse)
37#' library(highcharter)
38#' highcharts_demo() %>%
39#' hc_add_theme(hc_theme_ids_dark())
40#' @export
41hc_theme_ids_dark <-
42 function(fontFamily = "Fira Sans Condensed",
43 fontSize = "medium",
44 textColor = "#E0E0E3",
45 lowContrastColor = "#707073",
46 highContrastColor = "#F0F0F3",
47 palette = c(
48 '#EB7C31',
49 "#1F77B4",
50 "#2CA02C",
51 "#D62728",
52 "#9467BD",
53 "#8C564B",
54 "#E377C2",
55 "#7F7F7F",
56 "#BCBD22",
57 "#17BECF",
58 "#AEC7E8",
59 "#FFBB78",
60 "#98DF8A",
61 "#FF9896",
62 "#C5B0D5",
63 "#C49C94",
64 "#F7B6D2",
65 "#C7C7C7",
66 "#DBDB8D",
67 "#9EDAE5"
68 ),
69 backgroundColor = list(linearGradient = list(
70 x1 = 0,
71 y1 = 1,
72 x2 = 1,
73 y2 = 0
74 ),
75 stops = list(list(0, "#2a2a2b"),
76 list(1, "#3e3e3e"))),
77 titleColor = textColor,
78 subtitleColor = titleColor,
79 gridLineColor = lowContrastColor,
80 axisLabelColor = textColor,
81 axisLineColor = lowContrastColor,
82 minorGridLineColor = "#505053",
83 tickColor = lowContrastColor,
84 axisTitleColor = axisLabelColor,
85 tooltipBackgroundColor = "rgba(0, 0, 0, 0.85)",
86 tooltipColor = textColor,
87 dataLabelColor = textColor,
88 boxplotFillColor = "#505053",
89 candlestickColor = highContrastColor,
90 errorbarColor = candlestickColor,
91 legendColor = textColor,
92 legendHoverColor = highContrastColor,
93 legendHiddenColor = lowContrastColor,
94 creditsColor = lowContrastColor,
95 burgerMenuBackground = backgroundColor,
96 ...) {
97 theme <-
98 list(
99 colors = palette,
100 chart = list(
101 backgroundColor = backgroundColor,
102 style = list(fontFamily = fontFamily,
103 fontSize = fontSize),
104 plotBorderColor = "#606063"
105 ),
106 title = list(style = list(color = titleColor,
107 fontWeight = "600",
108 fontSize = "x-large")),
109 subtitle = list(style = list(color = subtitleColor,
110 fontSize = "large")),
111 xAxis = list(
112 gridLineColor = gridLineColor,
113 labels = list(style = list(color = axisLabelColor,
114 fontSize = "medium")),
115 lineColor = axisLineColor,
116 minorGridLineColor = minorGridLineColor,
117 tickColor = tickColor,
118 title = list(style = list(color = axisTitleColor,
119 fontSize = "medium"))
120 ),
121 yAxis = list(
122 gridLineColor = gridLineColor,
123 labels = list(style = list(color = axisLabelColor,
124 fontSize = "medium")),
125 lineColor = axisLineColor,
126 minorGridLineColor = minorGridLineColor,
127 tickColor = tickColor,
128 tickWidth = 1,
129 title = list(style = list(color = axisTitleColor,
130 fontSize = "medium"))
131 ),
132 tooltip = list(
133 backgroundColor = tooltipBackgroundColor,
134 style = list(color = tooltipColor,
135 fontSize = "medium")
136 ),
137 plotOptions = list(
138 series = list(
139 dataLabels = list(color = dataLabelColor,
140 fontSize = "medium"),
141 marker = list(lineColor = "#333")
142 ),
143 boxplot = list(fillColor = boxplotFillColor),
144 candlestick = list(lineColor = candlestickColor),
145 errorbar = list(color = errorbarColor)
146 ),
147 legend = list(
148 itemStyle = list(fontSize = "medium",
149 color = legendColor),
150 itemHoverStyle = list(color = legendHoverColor),
151 itemHiddenStyle = list(color = legendHiddenColor)
152 ),
153 credits = list(style = list(color = creditsColor)),
154 labels = list(style = list(color = "#707073")),
155
156 drilldown = list(
157 activeAxisLabelStyle = list(color = "#F0F0F3"),
158 activeDataLabelStyle = list(color = "#F0F0F3")
159 ),
160
161 navigation = list(buttonOptions = list(
162 symbolStroke = "#DDDDDD",
163 theme = list(fill = burgerMenuBackground)
164 )),
165
166 rangeSelector = list(
167 buttonTheme = list(
168 fill = "#505053",
169 stroke = "#000000",
170 style = list(color = "#CCC"),
171 states = list(
172 hover = list(
173 fill = "#707073",
174 stroke = "#000000",
175 style = list(color = "white")
176 ),
177 select = list(
178 fill = "#000003",
179 stroke = "#000000",
180 style = list(color = "white")
181 )
182 )
183 ),
184 inputBoxBorderColor = "#505053",
185 inputStyle = list(backgroundColor = "#333",
186 color = "silver"),
187 labelStyle = list(color = "silver")
188 ),
189
190 navigator = list(
191 handles = list(backgroundColor = "#666",
192 borderColor = "#AAA"),
193 maskFill = "rgba(255,255,255,0.1)",
194 series = list(color = "#7798BF",
195 lineColor = "#A6C7ED"),
196 xAxis = list(gridLineColor = "#505053")
197 ),
198
199 scrollbar = list(
200 barBackgroundColor = "#808083",
201 barBorderColor = "#808083",
202 buttonArrowColor = "#CCC",
203 buttonBackgroundColor = "#606063",
204 buttonBorderColor = "#606063",
205 rifleColor = "#FFF",
206 trackBackgroundColor = "#404043",
207 trackBorderColor = "#404043"
208 ),
209
210 legendBackgroundColor = "rgba(0, 0, 0, 0)",
211 background2 = "#233238",
212 dataLabelsColor = "#233238",
213 textColor = "#34495e",
214 maskColor = "rgba(255,255,255,0.3)",
215 contrastTextColor = highContrastColor
216 )
217
218 theme <- structure(theme, class = "hc_theme")
219
220 if (length(list(...)) > 0) {
221 theme <- hc_theme_merge(theme,
222 hc_theme(...))
223 }
224
225 theme
226 }
227
228#' Light IDS theme for \link[highcharter]{highcharter}
229#'
230#' See \code{\link{hc_theme_ids_dark}} for further documentation.
231#'
232#' @param ... named arguments to modify the theme
233#'
234#' @importFrom magrittr %>%
235#' @import tidyverse
236#' @import highcharter
237#'
238#' @examples
239#' library(tidyverse)
240#' library(highcharter)
241#' highcharts_demo() %>%
242#' hc_add_theme(hc_theme_ids_light())
243#' @export
244hc_theme_ids_light <- function(...) {
245 hc_theme_ids_dark(
246 backgroundColor = "#ffffff",
247 textColor = "#383838",
248 highContrastColor = "#101013",
249 lowContrastColor = "#E0E0E3",
250 tooltipBackgroundColor = "#ffffffe0",
251 boxplotFillColor = "#505053",
252 candlestickColor = "black",
253 errorbarColor = "black"
254 )
255}
256
257#' Monochrome IDS theme for \link[highcharter]{highcharter}
258#'
259#' See \code{\link{hc_theme_ids_dark}} for further documentation.
260#'
261#' @param ... named arguments to modify the theme
262#'
263#' @importFrom magrittr %>%
264#' @import tidyverse
265#' @import highcharter
266#'
267#' @examples
268#' library(tidyverse)
269#' library(highcharter)
270#' highcharts_demo() %>%
271#' hc_add_theme(hc_theme_ids_mono())
272#' @export
273hc_theme_ids_mono <- function(...) {
274 hc_theme_ids_dark(
275 palette = c(
276 "#000000", "#B2B0AD", "#737373", "#D8D7D6", "#B2B0AD", "#8C8984"
277 ),
278 backgroundColor = "white",
279 textColor = "black",
280 highContrastColor = "black",
281 lowContrastColor = "#A0A0A3",
282 tooltipBackgroundColor = "white",
283 boxplotFillColor = "#505053",
284 candlestickColor = "grey",
285 errorbarColor = "grey"
286 )
287}