blob: d9bca09439b4a34289c3b48d0343f34d28651f15 [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,
47 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,
92 labels = list(style = list(color = axisLabelColor,
93 fontSize = "medium")),
94 lineColor = axisLineColor,
95 minorGridLineColor = minorGridLineColor,
96 tickColor = tickColor,
97 title = list(style = list(color = axisTitleColor,
98 fontSize = "medium"))
99 ),
100 yAxis = list(
101 gridLineColor = gridLineColor,
102 labels = list(style = list(color = axisLabelColor,
103 fontSize = "medium")),
104 lineColor = axisLineColor,
105 minorGridLineColor = minorGridLineColor,
106 tickColor = tickColor,
107 tickWidth = 1,
108 title = list(style = list(color = axisTitleColor,
109 fontSize = "medium"))
110 ),
111 tooltip = list(
112 backgroundColor = tooltipBackgroundColor,
113 style = list(color = tooltipColor,
114 fontSize = "medium")
115 ),
116 plotOptions = list(
117 series = list(
118 dataLabels = list(color = dataLabelColor,
119 fontSize = "medium"),
120 marker = list(lineColor = "#333")
121 ),
122 boxplot = list(fillColor = boxplotFillColor),
123 candlestick = list(lineColor = candlestickColor),
124 errorbar = list(color = errorbarColor)
125 ),
126 legend = list(
127 itemStyle = list(fontSize = "medium",
128 color = legendColor),
129 itemHoverStyle = list(color = legendHoverColor),
130 itemHiddenStyle = list(color = legendHiddenColor)
131 ),
132 credits = list(style = list(color = creditsColor)),
133 labels = list(style = list(color = "#707073")),
Marc Kupietz52144812020-12-14 23:41:56 +0100134
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100135 drilldown = list(
136 activeAxisLabelStyle = list(color = "#F0F0F3"),
137 activeDataLabelStyle = list(color = "#F0F0F3")
138 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100139
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100140 navigation = list(buttonOptions = list(
141 symbolStroke = "#DDDDDD",
142 theme = list(fill = burgerMenuBackground)
143 )),
Marc Kupietz52144812020-12-14 23:41:56 +0100144
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100145 rangeSelector = list(
146 buttonTheme = list(
147 fill = "#505053",
148 stroke = "#000000",
149 style = list(color = "#CCC"),
150 states = list(
151 hover = list(
152 fill = "#707073",
153 stroke = "#000000",
154 style = list(color = "white")
155 ),
156 select = list(
157 fill = "#000003",
158 stroke = "#000000",
159 style = list(color = "white")
160 )
161 )
162 ),
163 inputBoxBorderColor = "#505053",
164 inputStyle = list(backgroundColor = "#333",
165 color = "silver"),
166 labelStyle = list(color = "silver")
167 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100168
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100169 navigator = list(
170 handles = list(backgroundColor = "#666",
171 borderColor = "#AAA"),
172 maskFill = "rgba(255,255,255,0.1)",
173 series = list(color = "#7798BF",
174 lineColor = "#A6C7ED"),
175 xAxis = list(gridLineColor = "#505053")
176 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100177
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100178 scrollbar = list(
179 barBackgroundColor = "#808083",
180 barBorderColor = "#808083",
181 buttonArrowColor = "#CCC",
182 buttonBackgroundColor = "#606063",
183 buttonBorderColor = "#606063",
184 rifleColor = "#FFF",
185 trackBackgroundColor = "#404043",
186 trackBorderColor = "#404043"
187 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100188
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100189 legendBackgroundColor = "rgba(0, 0, 0, 0)",
190 background2 = "#233238",
191 dataLabelsColor = "#233238",
192 textColor = "#34495e",
193 maskColor = "rgba(255,255,255,0.3)",
194 contrastTextColor = highContrastColor
195 )
Marc Kupietz52144812020-12-14 23:41:56 +0100196
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100197 theme <- structure(theme, class = "hc_theme")
Marc Kupietz52144812020-12-14 23:41:56 +0100198
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100199 if (length(list(...)) > 0) {
200 theme <- hc_theme_merge(theme,
201 hc_theme(...))
202 }
Marc Kupietz52144812020-12-14 23:41:56 +0100203
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100204 theme
205 }
206
207#' Light IDS theme for \link[highcharter]{highcharter}
208#'
209#' See \code{\link{hc_theme_ids_dark}} for further documentation.
210#'
Marc Kupietz52144812020-12-14 23:41:56 +0100211#' @inheritParams hc_theme_ids_dark
212#' @inheritDotParams hc_theme_ids_dark
213#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100214#' @importFrom magrittr %>%
215#' @import tidyverse
216#' @import highcharter
217#'
218#' @examples
219#' library(tidyverse)
220#' library(highcharter)
221#' highcharts_demo() %>%
222#' hc_add_theme(hc_theme_ids_light())
223#' @export
224hc_theme_ids_light <- function(...) {
225 hc_theme_ids_dark(
226 backgroundColor = "#ffffff",
Marc Kupietz52144812020-12-14 23:41:56 +0100227 textColor = textColor ,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100228 highContrastColor = "#101013",
229 lowContrastColor = "#E0E0E3",
230 tooltipBackgroundColor = "#ffffffe0",
231 boxplotFillColor = "#505053",
232 candlestickColor = "black",
233 errorbarColor = "black"
234 )
235}
236
237#' Monochrome IDS theme for \link[highcharter]{highcharter}
238#'
239#' See \code{\link{hc_theme_ids_dark}} for further documentation.
240#'
Marc Kupietz52144812020-12-14 23:41:56 +0100241#' @inheritParams hc_theme_ids_dark
242#' @inheritDotParams hc_theme_ids_dark
243#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100244#' @importFrom magrittr %>%
245#' @import tidyverse
246#' @import highcharter
247#'
248#' @examples
249#' library(tidyverse)
250#' library(highcharter)
251#' highcharts_demo() %>%
252#' hc_add_theme(hc_theme_ids_mono())
253#' @export
254hc_theme_ids_mono <- function(...) {
255 hc_theme_ids_dark(
Marc Kupietz52144812020-12-14 23:41:56 +0100256 palette = idsPaletteGreyscale,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100257 backgroundColor = "white",
258 textColor = "black",
259 highContrastColor = "black",
260 lowContrastColor = "#A0A0A3",
261 tooltipBackgroundColor = "white",
262 boxplotFillColor = "#505053",
263 candlestickColor = "grey",
264 errorbarColor = "grey"
265 )
266}