我已经在RStudio上通过向下钻取创建了一个堆积的柱状图,但是目前,我仅设法(使用在线示例)弄清楚了如何制作堆积的柱状图,但是每个条形都相同下钻辅助图。
我正在尝试将带有条形特定向下钻取元素的堆积柱形图制作到辅助图表(每个条形图/堆栈都将转到不同的向下钻取图,但是每个条形图中的每个分段都不会进行其他深入研究-如果可以的话。
目前只有2个酒吧,但实际上我会想要更多。
谢谢!
hc <- highchart() %>%
hc_chart(
type = "column",
events = list(
drilldown = JS(
"function(e) {
if (!e.seriesOptions) {
var chart = this;
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[1],
name: 'Criminal attacks',
data: [
['PAYE', 60],
['SA', 65]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[2],
name: 'Avoidance',
data: [
['PAYE', 4],
['SA', 25]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[3],
name: 'FTTRC',
data: [
['PAYE', 10],
['SA', 6]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[4],
name: 'Error',
data: [
['PAYE', 20],
['SA', 20]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[5],
name: 'Non-payment',
data: [
['PAYE', 5],
['SA', 10]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[6],
name: 'Legal interpretation',
data: [
['PAYE', 0],
['SA', 0]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[7],
name: 'Hidden economy',
data: [
['PAYE', 10],
['SA', 5]
]
});
chart.addSingleSeriesAsDrilldown(e.point, {
color: Highcharts.getOptions().colors[8],
name: 'Evasion',
data: [
['PAYE', 5],
['SA', 5]
]
});
chart.applyDrilldown();
}
}"
)
)
) %>%
hc_title(text = "Tax Assured - Payments") %>%
hc_xAxis(type = "category") %>%
hc_plotOptions(series = list(stacking = "normal")) %>%
hc_yAxis(max = 160) %>%
hc_add_series(
name = "Small business",
data = list(
list(name = "PAYE", y = 40, drilldown = T),
list(name = "SA", y = 35, drilldown = T)
)
) %>%
hc_add_series(
name = "Mid-size business",
data = list(
list(name = "PAYE", y = 60, drilldown = T),
list(name = "SA", y = 65, drilldown = T)
)
) %>%
hc_add_series(
name = "Large business",
data = list(
list(name = "PAYE", y = 20, drilldown = T),
list(name = "SA", y = 20, drilldown = T)
)
) %>%
hc_add_series(
name = "Individuals",
data = list(
list(name = "PAYE", y = 20, drilldown = T),
list(name = "SA", y = 20, drilldown = T)
)
) %>%
hc_add_series(
name = "Wealthy individuals",
data = list(
list(name = "PAYE", y = 20, drilldown = T),
list(name = "SA", y = 20, drilldown = T)
)
) %>%
hc_add_series(
name = "No segmentation",
data = list(
list(name = "PAYE", y = 0, drilldown = T),
list(name = "SA", y = 0, drilldown = T)
)
) %>%
hc_drilldown(
series = list()
)
hc