File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ Suggests:
3333 ggplot2,
3434 gt,
3535 knitr,
36+ plotly,
3637 rsconnect (>= 0.8.26),
3738 testthat (>= 3.1.7),
3839 withr,
Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ ggplot_theme_brand <- function(brand_yml) {
7373}
7474
7575
76-
7776# ' Create a gt theme using background and foreground colors
7877# '
7978# ' Create a gt theme that uses the specified background and
@@ -103,3 +102,33 @@ gt_theme_brand <- function(brand_yml) {
103102 brand <- yaml :: yaml.load_file(brand_yml )
104103 gt_theme_colors(brand $ color $ background , brand $ color $ foreground )
105104}
105+
106+ # ' Create a plotly theme using background and foreground colors
107+ # '
108+ # ' Create a plotly theme that uses the specified background and
109+ # ' foreground colors.
110+ # '
111+ # ' @param bg The background color
112+ # ' @param fg The foreground color
113+ # '
114+ # ' @export
115+ plotly_theme_colors <- function (bg , fg ) {
116+ (function (plot ) {
117+ plot | > plotly :: layout(paper_bgcolor = bg ,
118+ plot_bgcolor = bg ,
119+ font = list (color = fg )
120+ )
121+ })
122+ }
123+
124+ # ' Create a plotly theme from a brand.yml file
125+ # '
126+ # ' Create a plotly theme that uses colors from the brand file.
127+ # '
128+ # ' @param brand_yml The path to the brand.yml file
129+ # '
130+ # ' @export
131+ plotly_theme_brand <- function (brand_yml ) {
132+ brand <- yaml :: yaml.load_file(brand_yml )
133+ plotly_theme_colors(brand $ color $ background , brand $ color $ foreground )
134+ }
You can’t perform that action at this time.
0 commit comments