Skip to content

Commit c54564b

Browse files
committed
Allow custom settings to TAs' color
Users can now enter TAs' color settings by calling chartTheme(addTA = list(...)) to create custom theme parameters. BBands settings in .chart.theme is refactored to coordinate with addBBands function.
1 parent e8eac03 commit c54564b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

R/chartSeries.R

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ function(x,subset = NULL,
276276
fill="#F7F7F7",
277277
Expiry='#C9C9C9',
278278
BBands.col='#666666',BBands.fill="#F7F7F7",
279-
BBands=list(col='#666666',fill='#F7F7F7'),
279+
BBands=list(col=list(upper='#666666',
280+
lower='#666666',
281+
fill='#F7F7F7',
282+
ma='#D5D5D5')),
280283
theme.name='white.mono'
281284
),
282285
'black'=
@@ -294,7 +297,10 @@ function(x,subset = NULL,
294297
fill="#282828",
295298
Expiry='#383838',
296299
BBands.col='red',BBands.fill="#282828",
297-
BBands=list(col='red',fill='#282828'),
300+
BBands=list(col=list(upper='red',
301+
lower='red',
302+
fill='#282828',
303+
ma='#D5D5D5')),
298304
theme.name='black'
299305
),
300306
'black.mono'=
@@ -310,7 +316,10 @@ function(x,subset = NULL,
310316
main.col="#999999",sub.col="#999999",
311317
fill="#777777",
312318
Expiry='#383838',
313-
BBands=list(col='#DDDDDD',fill='#777777'),
319+
BBands=list(col=list(upper='#DDDDDD',
320+
lower='#DDDDDD',
321+
fill='#777777',
322+
ma='#D5D5D5')),
314323
BBands.col='#DDDDDD',BBands.fill="#777777",
315324
theme.name='black.mono'
316325
),
@@ -328,7 +337,10 @@ function(x,subset = NULL,
328337
fill="#F5F5F5",
329338
Expiry='#C9C9C9',
330339
BBands.col='orange',BBands.fill='#F5F5DF',
331-
BBands=list(col='orange',fill='#F5F5DF'),
340+
BBands=list(col=list(upper='orange',
341+
lower='orange',
342+
fill='#F5F5DF',
343+
ma='#D5D5D5')),
332344
theme.name='beige'
333345
),
334346
'wsj'=
@@ -534,9 +546,13 @@ function(x,
534546
}
535547

536548
cs$Env$length <- NROW(x)
537-
cs$Env$theme$bbands$col$fill <- theme$BBands.fill
538-
cs$Env$theme$bbands$col$upper <- theme$BBands.col
539-
cs$Env$theme$bbands$col$lower <- theme$BBands.col
549+
550+
# allow custom settings to TAs color
551+
# use chartTheme() to enter
552+
which.TA <- grep("add", names(theme))
553+
names(theme)[which.TA] <- gsub("^add", "", names(theme)[which.TA])
554+
cs$Env$theme <- append(cs$Env$theme, theme[which.TA])
555+
540556

541557
# change minor ticks to be downward
542558
exp <- expression(if (NROW(xdata[xsubset]) < 400) {

0 commit comments

Comments
 (0)