1

When creating a stackedAreaChart with rChart and nvd3, the default setting is Stacked. Is there a way to set Expanded as default? Here is the code:

dat <- data.frame(t=rep(0:23,each=4),var=rep(LETTERS[1:4],4),val=round(runif(4*24,0,50)))
p8 <- nPlot(val ~ t, group =  'var', data = dat, type = 'stackedAreaChart', id = 'chart')
p8

Doing p8$chart(stacked = TRUE) works for multiBarChart, but p8$chart(expanded = TRUE) does not work with stackedAreaChart. Any ideas?

user3874377
  • 255
  • 3
  • 10

1 Answers1

3

This should work

p8$chart(style = 'expand')
Erich Studerus
  • 557
  • 2
  • 10
  • 1
    It is generally considered helpful to explain why an answer solves a problem rather than just providing code, this way future visitors to the site who may not have the exact same question but a similar problem can also benefit from your answer – RobV Aug 28 '14 at 10:00
  • 1
    At the end of `nvd3` chart models, such as in this case `stackedArea` you will see a section with `getters` and `setters` [github source for stackedArea][1]. These generally give clues to what options are available. [These lines][2] tell us there is a `style` option with potential values as `stack`, `stream`, `stream-center`, `expand`, and `stack_percent`. [1]: https://github.com/novus/nvd3/blob/master/src/models/stackedArea.js#L257-L368 [2]: https://github.com/novus/nvd3/blob/master/src/models/stackedArea.js#L329-L357 – timelyportfolio Aug 28 '14 at 13:42