I was trying to adjust the Text-label of my Stacked Horizontal Bar chart using R implementation of amCharts. Below is my code :
library(RAmCharts)
Dat = data.frame('Type' = c('a', 'b'), 'Value1' = c(97.68648, 97.68648), 'Value2' = c(2.31351, 2.31351), 'z' = NA)
Fn = htmlwidgets::JS(
'function(value) {',
'return value+\'%\';',
'}')
P = amSerialChart(theme = 'light', categoryField = "Type", precision = 2, rotate = TRUE, hideCredits = TRUE, addClassNames = TRUE, plotAreaBorderAlpha = 1, plotAreaBorderColor = '#000') %>%
setDataProvider(dataProvider = Dat, keepNA = TRUE) %>%
addGraph(valueField = c("Value1"), fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', fixedColumnWidth = 50) %>%
addGraph(valueField = c("Value2"), fillAlphas = 0.8, bullet = "round", lineThickness = 0, type = 'column', fixedColumnWidth = 50) %>%
setBalloon(cornerRadius = 12, textAlign = "left", maxWidth = 1300)
P@valueAxes = list(list(stackType = 'regular', minimum = 0, maximum = 100))
P
I want to have the Text label to be displayed as in https://www.amcharts.com/demos/stacked-bar-chart/, however concatenated with '%' (as with my custom defined function Fn
here).
I hoped there could be a function like labelTextFunction
where I could implement above plan, but no success.
Can anyone please guide me how to achieve the same with R implementation of amCharts.
Thanks,
P@graphs[[1]]$labelText <- "[[value]]%"
– Martin Schmelzer