我有一个如下所示的 Dataframe ,我想绘制一个柱形图,在每一列的顶部显示变化值,该柱形图必须类似于richbourse site图。
qt <- data.frame(Symbole = c("STAC", "NEIC", "SAFC", "FTSC", "SCRC",
"PALC", "ABJC", "SOGC", "SNTS", "TTLC", "SLBC", "UNXC", "SICC",
"CBIBF", "BOABF", "SMBC", "BNBC", "BOAB", "CABC", "CFAC", "ECOC",
"ETIT", "NSBC", "NTLC", "ONTBF", "SDCC", "SEMC", "SGBC", "SHEC",
"SVOC", "TTLS", "TTRC", "UNLC", "STBC", "SPHC", "ORGT", "BOAN",
"BOAC", "SDSC", "BOAM", "SIBC", "CIEC", "BOAS", "BICC", "SIVC",
"PRSC"),
`Cours clôture (FCFA)` = c(1440, 740, 850, 1700, 920,7505, 1600, 5000,
14150, 2245, 165000, 2055, 4865, 9750, 6140,
7080, 2200, 5650, 1190, 1160, 4675, 23, 5755,
5275, 4195, 4450,735, 11200, 980, 0, 2050, 0,
0, 5850, 5100, 3905, 5145, 5310, 2500, 1380,
3985, 2150, 2500, 5855, 775, 4715),
`Variation(%)` = c(7.29,7.25, 6.51, 2.41, 2.17, 1.96, 1.54, 1.41, 0.71,
0.67, 0.61, 0.48,0.31, 0.3, 0.16, 0.07, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, -0.08, -0.38,
-0.64, -0.78, -0.94, -0.97, -1.09,-1.27, -2.33,
-2.72, -6.91, -7.1, -7.29),
position = c("Up","Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up",
"Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up",
"Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Up", "Down",
"Down", "Down", "Down", "Down", "Down", "Down", "Down", "Down",
"Down", "Down", "Down", "Down"))
这就是我所尝试的
library(highcharter)
hchart(qt, type = 'bar', hcaes(x = Symbole, y = `Variation(%)`,group = position ))%>%
hc_colors(colors = c("red", 'green'))```
我得到的图形是一般图形
,当我点击顶部
和当我点击触发
时
2条答案
按热度按时间06odsfpq1#
您可以使用dataLabels选项dataLabels.verticalAlign和dataLabels.y将位置设置为底部或顶部。
演示:https://jsfiddle.net/BlackLabel/rn35bud0/2/
API参考:
https://api.highcharts.com/highcharts/plotOptions.column.dataLabels.verticalAlign,
https://api.highcharts.com/highcharts/plotOptions.column.dataLabels.y
fxnxkyjh2#
最好的一个是