RHighchartermosaïc/ marimekko图表

时间:2018-04-16 11:26:32

标签: r r-highcharter marimekko-chart

我尝试在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))))

有没有人有任何想法?

0 个答案:

没有答案