我正在尝试使用
echarts4r
库生成 3D 条形图,但我发现一个问题,它仅接受 x 轴作为单个字母。
请参阅下面的工作示例:
library(echarts4r)
data <- data.frame(
x = c("A"
),
y = c(1
),
z = c(
35820
)
)
e_charts(data, x) %>%
e_bar_3d(y, z) %>%
e_x_axis_3d(type= "category") %>% e_y_axis_3d(type= "category") %>% e_z_axis_3d(type= "value")
这是不生成条形图的示例
library(echarts4r)
data <- data.frame(
x = c("HS"
),
y = c(1
),
z = c(
35820
)
)
e_charts(data, x) %>%
e_bar_3d(y, z) %>%
e_x_axis_3d(type= "category") %>% e_y_axis_3d(type= "category") %>% e_z_axis_3d(type= "value")
同意这看起来像一个错误。解决方法是使用列表列。为此,我使用
tibble
而不是 data.frame
并将 x 轴类别包装在 list
中:
library(echarts4r)
library(tibble)
data <- tibble(
x = list("HS"),
y = c(1),
z = c(
35820
)
)
e_charts(data, x) %>%
e_bar_3d(y, z) %>%
e_x_axis_3d(type = "category") %>%
e_y_axis_3d(type = "category") %>%
e_z_axis_3d(type = "value")