Reputation: 2400
The C3 chart prints OK if I don't try to explicitly state the values for the y-axis. However, I find the labels messy.
If I try to force y-axis label values, no labels are printed.
Yet, the third example shows that they can work.
Why do they not work in example #2?
R Script
library("c3")
library("tidyverse")
df <- structure(list(Date = structure(c(18503, 18504, 18505, 18506,
18507, 18508, 18509, 18510, 18511, 18512, 18513, 18514, 18515,
18516, 18517, 18518, 18519), class = "Date"), A = c(1.6, 1.6,
1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6), B = c(1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8,
1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8, 1.8), C = c(1.75, 1.75, 1.75,
1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75,
1.75, 1.75, 1.75), D = c(1.75, 1.75, 1.75, 1.75, 1.75, 1.75,
1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75
), E = c(1.75, 1.75, 1.75, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6,
1.6, 1.6, 1.6, 1.6, 1.6, 1.6, 1.6)), row.names = c(NA, -17L), class = c("tbl_df",
"tbl", "data.frame"))
# Example 1 ###############################
# Y-axis labels are there, but messy
df %>%
c3()
# Example 2 ###############################
# No Y-axis labels
df %>%
c3() %>%
tickAxis('y', values = c(0, 1, 2))
# Example 3 ###############################
# Clean Y-axis labels
data.frame(a = c(1,2,3,2), b = c(2,4,1,5)) %>%
c3() %>%
tickAxis('y', values = c(1, 2, 3, 4, 5))
Upvotes: 0
Views: 60
Reputation: 1210
It actually works. Your min
y axis value is 1.58
and max
is 1.8
. Since you have given c(0,1,2)
, it is not showing in the plot as it is magnified.
Try the below values and you will see the axis values.
df %>%
c3() %>%
tickAxis('y', values = c(1.6,1.65,1.7,1.8,1.81))
Output:
Upvotes: 1