gpt4 book ai didi

r - 在 Highcharter 工具提示中格式化日期时间

转载 作者:行者123 更新时间:2023-12-04 10:42:16 28 4
gpt4 key购买 nike

希望更改工具提示中日期时间的格式。我成功地为 x 轴做了它,但没有为工具提示。我已阅读文档,但找不到关于此的其他 R 特定主题。

日期位于 datetime_to_timestamp 函数所需的 Highchart 时间戳中。

library(highcharter)
library(tidyverse)

df <- data.frame(dateTime = c(1557705900000,1557705960000,1557706020000,1557706860000,1557706920000),
points = c(5,7,3,2,9))

highchart() %>%
hc_xAxis(type = "datetime", dateTimeLabelFormats = list(day = '%H:%M')) %>%
hc_add_series(df, type = "scatter",
hcaes(x = dateTime, y = points)) %>%
hc_tooltip(crosshairs = TRUE, dateTimeLabelFormats = list(day = '%H:%M'))

# highchart() %>%
# hc_xAxis(type = "datetime", dateTimeLabelFormats = list(day = '%H:%M')) %>%
# hc_add_series(df, type = "scatter",
# hcaes(x = dateTime, y = points)) %>%
# hc_tooltip(crosshairs = TRUE, dateTimeLabelFormats = '%H:%M')

工具提示格式应该类似于 x 轴格式。

enter image description here

有什么想法吗?

最佳答案

尝试pointFormat

highchart() %>%
hc_xAxis(type = "datetime", dateTimeLabelFormats = list(day = '%H:%M')) %>%
hc_add_series(df, type = "scatter",
hcaes(x = dateTime, y = points)) %>%
hc_tooltip(crosshairs = TRUE, pointFormat = "x: {point.x:%H:%M} <br> y: {point.y}")

关于r - 在 Highcharter 工具提示中格式化日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56192572/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com