3D 条形图错误

问题描述 投票:0回答:1

我正在尝试使用

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")

看到x轴没有很好地显示:

r shiny 3d bar-chart echarts4r
1个回答
0
投票

同意这看起来像一个错误。解决方法是使用列表列。为此,我使用

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")

© www.soinside.com 2019 - 2024. All rights reserved.