highcharts 用highcharter制作双Y轴分组条形图

sd2nnvve  于 2022-11-10  发布在  Highcharts
关注(0)|答案(1)|浏览(179)

我试图建立一个分组条形图的基础上,两个Y轴与包highcharter。
我想得到类似于下图的东西:

下面是一个虚拟数据集:

dummy_df <- data.frame(Label = c("A","B", "C"),
                                     value1 = c(34,59,12),
                                     Value2 = c(397,2678,212))

单Y轴输出:

dummy_df %>% 
    hchart('bar', hcaes(x = 'Label', y = 'value1', group = 'value1'))
ldioqlga

ldioqlga1#

dummy_df <- data.frame(Label = c("A","B", "C"),
                       value1 = c(34,59,12),
                       value2 = c(397,2678,212))

highchart() %>%
  hc_add_series(type="column",name = "Order Items <b>Count</b>", data = dummy_df$value1 )%>%
  hc_add_series(type="column",name = "Order Items <b>Total Gross Margin</b>", data = dummy_df$value2, yAxis =1 )%>%
  hc_xAxis(categories = dummy_df$Label)%>%
  hc_yAxis_multiples(
    list(lineWidth = 0,
         title = list(text = "Order Items <b>Count</b>")),
    list(showLastLabel = FALSE, opposite = TRUE,
         title = list(text = "Order Items <b>Total Gross Margin</b>"))
  )

为您提供:

相关问题