如果我不尝试明确声明y轴的值,则C3图表将显示OK。但是,我发现标签很乱。
如果我尝试强制使用y轴标签值,则不会打印任何标签。
但是,第三个示例表明它们可以工作。
为什么它们在示例2中不起作用?
R脚本
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))