【发布时间】:2020-07-06 21:53:30
【问题描述】:
我想显示一个 highcharter 堆积条形图,其中行标签被修剪,前五个字符没有显示。但是,在工具提示中应该显示完整的类别名称。
在上面的示例中,作为 xAxis 上的类别,我希望只有“2012”、“2013”、..,而在工具提示中应该显示整个类别名称。 这是我的代码
bs.table = data.frame(
Closing.Date = c("Line 2012", "Year 2013", "Year 2014", "Year 2015", "Year 2016"),
Non.Current.Assets = c(40.4, 30.3, 20.4, 34.5, 20),
Current.Assets = c(3.2, 3.3, 2.4, 3.5, 2)
)
hc <- highchart() %>%
hc_chart(type = "bar") %>%
hc_plotOptions(series = list(stacking = "normal")) %>%
hc_xAxis(categories = bs.table$Closing.Date,
lineColor = 'transparent',
tickWidth = 0,
labels = list(enable = TRUE,
align = 'left',
x = 5,
style = list(fontSize = '1em',color = '#fff'))) %>%
hc_add_series(name ="Non Current Assets",
data = bs.table$Current.Assets,
stack = "Assets",
dataLabels = list(enabled = TRUE,
inside = TRUE,
align = "right",
style = list(fontSize = '1em',color = '#fff'))) %>%
hc_add_series(name = "Current Assets",
data = bs.table$Non.Current.Assets,
stack = "Assets",
dataLabels = list(enabled = TRUE, inside = FALSE, align = "right",
style = list(fontSize = '1em',color = '#fff')) ) %>%
hc_legend(enabled = FALSE) %>%
hc_tooltip(shared = TRUE,
headerFormat = '<b>Statement {point.x}</b><br>',
pointFormat = '<b>{series.name}:</b> {point.y} <br>',
footerFormat = '<b>Total: {point.total} </b>')
非常感谢!
【问题讨论】:
标签: r-highcharter