blob: 300e7fbe13a8f23baa45f02b72644ee600fe5f1d [file] [log] [blame]
Marc Kupietzcd7acbd2020-12-10 14:02:52 +01001#' Dark IDS theme for \link[highcharter]{highcharter}
2#'
Marc Kupietz52144812020-12-14 23:41:56 +01003#' @param fontFamily font family
Marc Kupietzcd7acbd2020-12-10 14:02:52 +01004#' @param fontSize default font size
5#' @param textColor default text color
Marc Kupietz52144812020-12-14 23:41:56 +01006#' @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
Marc Kupietzcd7acbd2020-12-10 14:02:52 +01009#' @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",
Marc Kupietz52144812020-12-14 23:41:56 +010044 textColor = textColorDark,
45 lowContrastColor = lowContrastColorDark,
46 highContrastColor = highContrastColorDark,
Marc Kupietz161a86a2021-02-02 14:40:23 +010047 palette = idsPalette(),
Marc Kupietzcd7acbd2020-12-10 14:02:52 +010048 backgroundColor = list(linearGradient = list(
49 x1 = 0,
50 y1 = 1,
51 x2 = 1,
52 y2 = 0
53 ),
54 stops = list(list(0, "#2a2a2b"),
55 list(1, "#3e3e3e"))),
56 titleColor = textColor,
57 subtitleColor = titleColor,
58 gridLineColor = lowContrastColor,
59 axisLabelColor = textColor,
60 axisLineColor = lowContrastColor,
61 minorGridLineColor = "#505053",
62 tickColor = lowContrastColor,
63 axisTitleColor = axisLabelColor,
64 tooltipBackgroundColor = "rgba(0, 0, 0, 0.85)",
65 tooltipColor = textColor,
66 dataLabelColor = textColor,
67 boxplotFillColor = "#505053",
68 candlestickColor = highContrastColor,
69 errorbarColor = candlestickColor,
70 legendColor = textColor,
71 legendHoverColor = highContrastColor,
72 legendHiddenColor = lowContrastColor,
73 creditsColor = lowContrastColor,
74 burgerMenuBackground = backgroundColor,
75 ...) {
76 theme <-
77 list(
78 colors = palette,
79 chart = list(
80 backgroundColor = backgroundColor,
81 style = list(fontFamily = fontFamily,
82 fontSize = fontSize),
83 plotBorderColor = "#606063"
84 ),
85 title = list(style = list(color = titleColor,
86 fontWeight = "600",
87 fontSize = "x-large")),
88 subtitle = list(style = list(color = subtitleColor,
89 fontSize = "large")),
90 xAxis = list(
91 gridLineColor = gridLineColor,
Marc Kupietze8d0a8e2020-12-28 13:36:21 +010092 gridLineDashStyle = "ShortDot",
93 gridLineWidth = 1,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +010094 labels = list(style = list(color = axisLabelColor,
95 fontSize = "medium")),
96 lineColor = axisLineColor,
97 minorGridLineColor = minorGridLineColor,
98 tickColor = tickColor,
99 title = list(style = list(color = axisTitleColor,
100 fontSize = "medium"))
101 ),
102 yAxis = list(
103 gridLineColor = gridLineColor,
104 labels = list(style = list(color = axisLabelColor,
105 fontSize = "medium")),
106 lineColor = axisLineColor,
107 minorGridLineColor = minorGridLineColor,
108 tickColor = tickColor,
109 tickWidth = 1,
110 title = list(style = list(color = axisTitleColor,
111 fontSize = "medium"))
112 ),
113 tooltip = list(
114 backgroundColor = tooltipBackgroundColor,
115 style = list(color = tooltipColor,
116 fontSize = "medium")
117 ),
118 plotOptions = list(
119 series = list(
120 dataLabels = list(color = dataLabelColor,
121 fontSize = "medium"),
122 marker = list(lineColor = "#333")
123 ),
124 boxplot = list(fillColor = boxplotFillColor),
125 candlestick = list(lineColor = candlestickColor),
126 errorbar = list(color = errorbarColor)
127 ),
128 legend = list(
129 itemStyle = list(fontSize = "medium",
Marc Kupietz835bf3a2021-02-02 14:50:03 +0100130 fontWeight="normal",
131 opacity="100%",
132 color = highContrastColor),
133 itemHoverStyle = list(
134 fontSize = "large"
135 ),
136 itemHiddenStyle = list(opacity="40%", fillColor="inherit", color="inherit")
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100137 ),
138 credits = list(style = list(color = creditsColor)),
139 labels = list(style = list(color = "#707073")),
Marc Kupietz52144812020-12-14 23:41:56 +0100140
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100141 drilldown = list(
142 activeAxisLabelStyle = list(color = "#F0F0F3"),
143 activeDataLabelStyle = list(color = "#F0F0F3")
144 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100145
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100146 navigation = list(buttonOptions = list(
147 symbolStroke = "#DDDDDD",
148 theme = list(fill = burgerMenuBackground)
149 )),
Marc Kupietz52144812020-12-14 23:41:56 +0100150
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100151 rangeSelector = list(
152 buttonTheme = list(
153 fill = "#505053",
154 stroke = "#000000",
155 style = list(color = "#CCC"),
156 states = list(
157 hover = list(
158 fill = "#707073",
159 stroke = "#000000",
160 style = list(color = "white")
161 ),
162 select = list(
163 fill = "#000003",
164 stroke = "#000000",
165 style = list(color = "white")
166 )
167 )
168 ),
169 inputBoxBorderColor = "#505053",
170 inputStyle = list(backgroundColor = "#333",
171 color = "silver"),
172 labelStyle = list(color = "silver")
173 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100174
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100175 navigator = list(
176 handles = list(backgroundColor = "#666",
177 borderColor = "#AAA"),
178 maskFill = "rgba(255,255,255,0.1)",
179 series = list(color = "#7798BF",
180 lineColor = "#A6C7ED"),
181 xAxis = list(gridLineColor = "#505053")
182 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100183
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100184 scrollbar = list(
185 barBackgroundColor = "#808083",
186 barBorderColor = "#808083",
187 buttonArrowColor = "#CCC",
188 buttonBackgroundColor = "#606063",
189 buttonBorderColor = "#606063",
190 rifleColor = "#FFF",
191 trackBackgroundColor = "#404043",
192 trackBorderColor = "#404043"
193 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100194
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100195 legendBackgroundColor = "rgba(0, 0, 0, 0)",
196 background2 = "#233238",
197 dataLabelsColor = "#233238",
198 textColor = "#34495e",
199 maskColor = "rgba(255,255,255,0.3)",
200 contrastTextColor = highContrastColor
201 )
Marc Kupietz52144812020-12-14 23:41:56 +0100202
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100203 theme <- structure(theme, class = "hc_theme")
Marc Kupietz52144812020-12-14 23:41:56 +0100204
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100205 if (length(list(...)) > 0) {
206 theme <- hc_theme_merge(theme,
207 hc_theme(...))
208 }
Marc Kupietz52144812020-12-14 23:41:56 +0100209
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100210 theme
211 }
212
213#' Light IDS theme for \link[highcharter]{highcharter}
214#'
215#' See \code{\link{hc_theme_ids_dark}} for further documentation.
216#'
Marc Kupietz52144812020-12-14 23:41:56 +0100217#' @inheritParams hc_theme_ids_dark
218#' @inheritDotParams hc_theme_ids_dark
219#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100220#' @importFrom magrittr %>%
221#' @import tidyverse
222#' @import highcharter
223#'
224#' @examples
225#' library(tidyverse)
226#' library(highcharter)
227#' highcharts_demo() %>%
228#' hc_add_theme(hc_theme_ids_light())
229#' @export
230hc_theme_ids_light <- function(...) {
231 hc_theme_ids_dark(
232 backgroundColor = "#ffffff",
Marc Kupietz52144812020-12-14 23:41:56 +0100233 textColor = textColor ,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100234 highContrastColor = "#101013",
235 lowContrastColor = "#E0E0E3",
236 tooltipBackgroundColor = "#ffffffe0",
237 boxplotFillColor = "#505053",
238 candlestickColor = "black",
239 errorbarColor = "black"
240 )
241}
242
243#' Monochrome IDS theme for \link[highcharter]{highcharter}
244#'
245#' See \code{\link{hc_theme_ids_dark}} for further documentation.
246#'
Marc Kupietz52144812020-12-14 23:41:56 +0100247#' @inheritParams hc_theme_ids_dark
248#' @inheritDotParams hc_theme_ids_dark
249#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100250#' @importFrom magrittr %>%
251#' @import tidyverse
252#' @import highcharter
253#'
254#' @examples
255#' library(tidyverse)
256#' library(highcharter)
257#' highcharts_demo() %>%
258#' hc_add_theme(hc_theme_ids_mono())
259#' @export
260hc_theme_ids_mono <- function(...) {
261 hc_theme_ids_dark(
Marc Kupietz52144812020-12-14 23:41:56 +0100262 palette = idsPaletteGreyscale,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100263 backgroundColor = "white",
264 textColor = "black",
265 highContrastColor = "black",
266 lowContrastColor = "#A0A0A3",
267 tooltipBackgroundColor = "white",
268 boxplotFillColor = "#505053",
269 candlestickColor = "grey",
270 errorbarColor = "grey"
271 )
272}