2

我尝试按照以下示例在 R Highcharter 中创建一个 marimekko 图表:

http://jsfiddle.net/highcharts/h2np93k1/

我似乎无法让树图的sortIndex工作,我的代码如下:

parentid <- c(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
sortIndex <- c(0, 1, 2, 3, 4, 0, 1, 2, 3, 4)
child <- c("Alpha", "Alpha", "Alpha", "Alpha", "Alpha", "Beta", "Beta", "Beta", "Beta", "Beta")
childid <- c(100, 100, 100, 100, 100, 200, 200, 200, 200, 200)
colorid <- c(100, 100, 100, 100, 100, 200, 200, 200, 200, 200)
parent <- c("Parent 1", "Parent 2", "Parent 3", "Parent 4", "Parent 5", "Parent 1", "Parent 2", "Parent 3", "Parent 4", "Parent 5")
value <- c(10, 60, 70, 20, 90, 50, 30, 10, 90, 10)
data <- data.frame(parentid, sortIndex, child, childid, colorid, parent, value)

hctreemap2(data, group_vars=c("parentid", "childid"),
           size_var="value",
           color_var="colorid",
           layoutAlgorithm='stripes',
           alternateStartingDirection = T,
           stacking="percent",
           levelIsConstant = F,
           sortIndex=sortIndex,
           levels = list(
             list(level=1, dataLabels = list(enabled=T, align='left', verticalAlign='top'), borderWidth=3),
             list(level=2, dataLabels = list(enabled=T))))

有人有什么想法吗?

4

0 回答 0