2

I wonder if it is possible to do a stacked barplot combined with a line in a multiChart plot from rCharts/NVD3 or similiar.

A small example (copied from the demo section of rCharts on github could look like this:

library(dplyr)
library(tidyr)
library(data.table)
library(rCharts)

data(economics, package = 'ggplot2')

ecm <- reshape2::melt(economics[,c('date', 'uempmed', 'psavert', 'unemploy')], id = 'date')

p12 <- nPlot(value ~ date, group = 'variable', data = ecm, type = 'multiChart')
p12$params$multi = list(
  uempmed = list(type="bar",yAxis=1),
  psavert = list(type="bar",yAxis=1),
  unemploy = list(type="line",yAxis=2)
)
p12$setTemplate(script = system.file(
  "/libraries/nvd3/layouts/multiChart.html",
  package = "rCharts"
))
p12

This results in this picture: enter image description here

What I want is that the blue bars are stacked, not grouped. Is this possible?

pfuhlert
  • 533
  • 4
  • 16

0 Answers0