blob: 9030d90dd0a6fc0cb725a60bc993a115d511bcbf [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,
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",
130 color = legendColor),
131 itemHoverStyle = list(color = legendHoverColor),
132 itemHiddenStyle = list(color = legendHiddenColor)
133 ),
134 credits = list(style = list(color = creditsColor)),
135 labels = list(style = list(color = "#707073")),
Marc Kupietz52144812020-12-14 23:41:56 +0100136
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100137 drilldown = list(
138 activeAxisLabelStyle = list(color = "#F0F0F3"),
139 activeDataLabelStyle = list(color = "#F0F0F3")
140 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100141
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100142 navigation = list(buttonOptions = list(
143 symbolStroke = "#DDDDDD",
144 theme = list(fill = burgerMenuBackground)
145 )),
Marc Kupietz52144812020-12-14 23:41:56 +0100146
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100147 rangeSelector = list(
148 buttonTheme = list(
149 fill = "#505053",
150 stroke = "#000000",
151 style = list(color = "#CCC"),
152 states = list(
153 hover = list(
154 fill = "#707073",
155 stroke = "#000000",
156 style = list(color = "white")
157 ),
158 select = list(
159 fill = "#000003",
160 stroke = "#000000",
161 style = list(color = "white")
162 )
163 )
164 ),
165 inputBoxBorderColor = "#505053",
166 inputStyle = list(backgroundColor = "#333",
167 color = "silver"),
168 labelStyle = list(color = "silver")
169 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100170
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100171 navigator = list(
172 handles = list(backgroundColor = "#666",
173 borderColor = "#AAA"),
174 maskFill = "rgba(255,255,255,0.1)",
175 series = list(color = "#7798BF",
176 lineColor = "#A6C7ED"),
177 xAxis = list(gridLineColor = "#505053")
178 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100179
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100180 scrollbar = list(
181 barBackgroundColor = "#808083",
182 barBorderColor = "#808083",
183 buttonArrowColor = "#CCC",
184 buttonBackgroundColor = "#606063",
185 buttonBorderColor = "#606063",
186 rifleColor = "#FFF",
187 trackBackgroundColor = "#404043",
188 trackBorderColor = "#404043"
189 ),
Marc Kupietz52144812020-12-14 23:41:56 +0100190
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100191 legendBackgroundColor = "rgba(0, 0, 0, 0)",
192 background2 = "#233238",
193 dataLabelsColor = "#233238",
194 textColor = "#34495e",
195 maskColor = "rgba(255,255,255,0.3)",
196 contrastTextColor = highContrastColor
197 )
Marc Kupietz52144812020-12-14 23:41:56 +0100198
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100199 theme <- structure(theme, class = "hc_theme")
Marc Kupietz52144812020-12-14 23:41:56 +0100200
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100201 if (length(list(...)) > 0) {
202 theme <- hc_theme_merge(theme,
203 hc_theme(...))
204 }
Marc Kupietz52144812020-12-14 23:41:56 +0100205
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100206 theme
207 }
208
209#' Light IDS theme for \link[highcharter]{highcharter}
210#'
211#' See \code{\link{hc_theme_ids_dark}} for further documentation.
212#'
Marc Kupietz52144812020-12-14 23:41:56 +0100213#' @inheritParams hc_theme_ids_dark
214#' @inheritDotParams hc_theme_ids_dark
215#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100216#' @importFrom magrittr %>%
217#' @import tidyverse
218#' @import highcharter
219#'
220#' @examples
221#' library(tidyverse)
222#' library(highcharter)
223#' highcharts_demo() %>%
224#' hc_add_theme(hc_theme_ids_light())
225#' @export
226hc_theme_ids_light <- function(...) {
227 hc_theme_ids_dark(
228 backgroundColor = "#ffffff",
Marc Kupietz52144812020-12-14 23:41:56 +0100229 textColor = textColor ,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100230 highContrastColor = "#101013",
231 lowContrastColor = "#E0E0E3",
232 tooltipBackgroundColor = "#ffffffe0",
233 boxplotFillColor = "#505053",
234 candlestickColor = "black",
235 errorbarColor = "black"
236 )
237}
238
239#' Monochrome IDS theme for \link[highcharter]{highcharter}
240#'
241#' See \code{\link{hc_theme_ids_dark}} for further documentation.
242#'
Marc Kupietz52144812020-12-14 23:41:56 +0100243#' @inheritParams hc_theme_ids_dark
244#' @inheritDotParams hc_theme_ids_dark
245#'
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100246#' @importFrom magrittr %>%
247#' @import tidyverse
248#' @import highcharter
249#'
250#' @examples
251#' library(tidyverse)
252#' library(highcharter)
253#' highcharts_demo() %>%
254#' hc_add_theme(hc_theme_ids_mono())
255#' @export
256hc_theme_ids_mono <- function(...) {
257 hc_theme_ids_dark(
Marc Kupietz52144812020-12-14 23:41:56 +0100258 palette = idsPaletteGreyscale,
Marc Kupietzcd7acbd2020-12-10 14:02:52 +0100259 backgroundColor = "white",
260 textColor = "black",
261 highContrastColor = "black",
262 lowContrastColor = "#A0A0A3",
263 tooltipBackgroundColor = "white",
264 boxplotFillColor = "#505053",
265 candlestickColor = "grey",
266 errorbarColor = "grey"
267 )
268}