【问题标题】:R Highcharter - How to customize tooltips for multiple y-axes?R Highcharter - 如何为多个 y 轴自定义工具提示?
【发布时间】:2020-11-05 15:30:53
【问题描述】:

是否可以为多个 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 = "&lt;b&gt;{series.name}: ${point.y:,.0f}",pointFormat = "&lt;b&gt;{series.name}: {point.y:,.2f}%")),但不起作用。

【问题讨论】:

  • @Ben,当您设置shared = TRUE 时,所有工具提示都会显示在一个窗口中。这就是shared 的意思。我正在尝试做的是自定义个人工具提示。

标签: r r-highcharter


【解决方案1】:

您可以为每个 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}%"))

【讨论】:

    猜你喜欢
    • 2018-04-07
    • 1970-01-01
    • 2020-03-29
    • 2021-09-07
    • 1970-01-01
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 2018-11-17
    相关资源
    最近更新 更多