R Highcharter - 如何为多个 y 轴自定义工具提示?
R Highcharter - How to customize tooltips for multiple y-axes?
是否可以为多个 y 轴自定义工具提示点格式?在下面的简单示例中,我有两个 y 轴:一个用于值,一个用于百分比。我希望工具提示为值系列显示 ${point.y:,.0f}
,为百分比系列显示 {point.y:,.2f}%
。
highchart() %>%
hc_yAxis_multiples(list(title=list(text="<b>Value<b>"),
showLastLabel = FALSE,opposite = FALSE),
list(title=list(text="<b>Percent<b>"),
showLastLabel = FALSE, opposite = T)) %>%
hc_add_series(c(seq(100,110)), yAxis=0) %>%
hc_add_series(c(seq(1,10)), yAxis=1)
我尝试添加 hc_tooltip(list(pointFormat = "<b>{series.name}: ${point.y:,.0f}",pointFormat = "<b>{series.name}: {point.y:,.2f}%"))
,但它不起作用。
您可以为每个人指定工具提示hc_add_series
:
highchart() %>%
hc_yAxis_multiples(list(title=list(text="<b>Value<b>"),
showLastLabel = FALSE,opposite = FALSE),
list(title=list(text="<b>Percent<b>"),
showLastLabel = FALSE, opposite = T)) %>%
hc_add_series(c(seq(100,110)), yAxis=0,
tooltip = list(pointFormat = "<b>{series.name}: ${point.y:,.0f}")) %>%
hc_add_series(c(seq(1,10)), yAxis=1,
tooltip = list(pointFormat = "<b>{series.name}: {point.y:,.2f}%"))
是否可以为多个 y 轴自定义工具提示点格式?在下面的简单示例中,我有两个 y 轴:一个用于值,一个用于百分比。我希望工具提示为值系列显示 ${point.y:,.0f}
,为百分比系列显示 {point.y:,.2f}%
。
highchart() %>%
hc_yAxis_multiples(list(title=list(text="<b>Value<b>"),
showLastLabel = FALSE,opposite = FALSE),
list(title=list(text="<b>Percent<b>"),
showLastLabel = FALSE, opposite = T)) %>%
hc_add_series(c(seq(100,110)), yAxis=0) %>%
hc_add_series(c(seq(1,10)), yAxis=1)
我尝试添加 hc_tooltip(list(pointFormat = "<b>{series.name}: ${point.y:,.0f}",pointFormat = "<b>{series.name}: {point.y:,.2f}%"))
,但它不起作用。
您可以为每个人指定工具提示hc_add_series
:
highchart() %>%
hc_yAxis_multiples(list(title=list(text="<b>Value<b>"),
showLastLabel = FALSE,opposite = FALSE),
list(title=list(text="<b>Percent<b>"),
showLastLabel = FALSE, opposite = T)) %>%
hc_add_series(c(seq(100,110)), yAxis=0,
tooltip = list(pointFormat = "<b>{series.name}: ${point.y:,.0f}")) %>%
hc_add_series(c(seq(1,10)), yAxis=1,
tooltip = list(pointFormat = "<b>{series.name}: {point.y:,.2f}%"))