Closed hendrikvanb closed 6 years ago
It is possible, you just need to allocate the axes via the c3 data object. Unfortunately, I have not done a good job of documenting this.
Please try the following:
data %>% c3(x = 'date',
axes = list(a = 'y',
b = 'y2')) %>%
c3_mixedGeom(types = list(a='line',
b='area')) %>%
y2Axis()
Note the axes =
argument. This is where the work is done, y2Axis()
simply makes the second axis visible.
Thank you, Matt! This works a treat and also nicely illustrates how to specify other data attributes. Your help (and the excellent package) is much appreciated.
you are most welcome. closed with commit 706bf33
I'm trying to create a chart where one series (
a
) is mapped to the primary y-axis as a line chart and another series on a different scale (b
) is mapped to the secondary y-axis as an area chart. There is an exampl e that illustrates this kind of dual y-axis mapping in c3.js, but am am not sure how to translate this example for use with the c3 package in R. I've been able to implement something like this with ggplot2 using the following MWE:However, I'm struggling to recreate something similar using c3:
Is this currently possible with c3? If so, where am I going wrong? Thanks!