我们可以使用rcharts绘制Highcharts中的Grouped_Categories图表吗?

时间:2015-09-30 10:00:11

标签: r highcharts rcharts

我真的很感激rCharts包被创建来做很多很酷的东西,非常喜欢它。此外,我很感兴趣使用R来绘制blacklabel的groups_categories图表(Highcharts)(请参阅下面的链接)。

https://github.com/blacklabel/grouped_categories

json格式的grouped_categories示例:

xAxis: {
    categories: [{
        name: "Fruit",
        categories: ["Apple", "Banana", "Orange"]
    }, {
        name: "Vegetable",
        categories: ["Carrot", "Potato", "Tomato"]
    }, {
        name: "Fish",
        categories: ["Cod", "Salmon", "Tuna"]
    }]
}

你能告诉我rCharts包能否这样做?如果是的话,你能给我一些简单的示例R代码用于groups_categories图表仅供我参考吗?

欣赏并感谢

1 个答案:

答案 0 :(得分:0)

您好,您可以使用rCharts执行此操作,只需使用addAssets即可包含grouped_categories JS lib。

library("rCharts")
h1 <- Highcharts$new()
h1$chart(
  type = "column"
)
h1$series(
  list(
    list(
      data = list(4, 14, 18, 5, 6, 5, 14, 15, 18)
    )
  )
)
h1$xAxis(
  categories = list(
    list(
      name = "Fruit",
      categories = list("Apple", "Banana", "Orange")
    ),
    list(
      name = "Vegetable",
      categories = list("Carrot", "Potato", "Tomato")
    ),
    list(
      name = "Fish",
      categories = list("Cod", "Salmon", "Tuna")
    )
  )
)
h1$addAssets(js = "https://raw.githubusercontent.com/blacklabel/grouped_categories/master/grouped-categories.js")
h1

Etvoilà