Highcharter 悬停显示不正确的点
Highcharter hover showing incorrect point
我遇到一个问题,当我为 Shiny 创建高图时,悬停功能无法正常工作。我已经大量使用 highcharter 并且从未遇到过这个问题,但是出于某种原因,在这个仪表板上,每当我将鼠标悬停在一个点上时,它要么不会记录悬停,要么会提供不同点的工具提示。屏幕截图示例在这里。以前有人遇到过这个问题吗?红色箭头显示截取此屏幕截图时我的鼠标所在的位置。
我的代码如下(请注意,fluidRow() 中有两个图表,但是删除一个并使图表占据整行并不能解决问题)。:
`############
UI
中的代码
fluidRow(align = "center",splitLayout(cellWidths = c("50%","50%"),
withLoader(highchartOutput(outputId = "lineChart1", height = 500, width = 700),type = "html",loader = "dnaspin"),
withLoader(highchartOutput(outputId = "lineChart2", height = 450, width = 700),type = "html",loader = "dnaspin")
)
)
`
#
实际图形的代码(在服务器中)
output$lineChart1 <- renderHighchart({
impactData <- read.csv("IMPACT_dash.csv")
colnames(impactData) <- c("Week","notAtAll","notButWill","hasSomewhat",
"hasConsiderably","hasDevastating")
highchart() %>%
hc_add_series(data = impactData, "line", color = "#404040", hcaes(x = Week, y = notAtAll),
name = "It has not and will probably never impact my life at all") %>%
hc_add_series(data = impactData, "line", color = "#8f8f8f", hcaes(x = Week, y = notButWill),
name = "It has not but will probably impact my life in the future") %>%
hc_add_series(data = impactData, color = "#91ad80", "line", hcaes(x = Week, y = hasSomewhat),
name = "It has impacted my life somewhat") %>%
hc_add_series(data = impactData, color = "#8fc96b", "line", hcaes(x = Week, y = hasConsiderably),
name = "It has impacted my life considerably") %>%
hc_add_series(data = impactData, color = "#83d64f", "line", hcaes(x = Week, y = hasDevastating),
name = "It has had a devastating impact on my life") %>%
hc_plotOptions(
series = list(
showInLegend = T,
pointFormat = "{point.y}%"
), column = list(colorByPoint = T)
) %>%
hc_yAxis(title = list(text = "Percent"),
#lables = list(format("{value}%"),
max = 100) %>%
hc_xAxis(title = list(text = "Week"), categories = impactData$Week) %>%
hc_title(text = "") %>%
hc_tooltip(pointFormat = "{point.y}%")
})
`
示例数据:
找到答案了。这是因为在我的仪表板中,我已将其设置为在打开时将页面显示为缩小 80%。这导致图表中的悬停出现问题。导致问题的代码如下
我遇到一个问题,当我为 Shiny 创建高图时,悬停功能无法正常工作。我已经大量使用 highcharter 并且从未遇到过这个问题,但是出于某种原因,在这个仪表板上,每当我将鼠标悬停在一个点上时,它要么不会记录悬停,要么会提供不同点的工具提示。屏幕截图示例在这里。以前有人遇到过这个问题吗?红色箭头显示截取此屏幕截图时我的鼠标所在的位置。
我的代码如下(请注意,fluidRow() 中有两个图表,但是删除一个并使图表占据整行并不能解决问题)。:
`############
UI
中的代码fluidRow(align = "center",splitLayout(cellWidths = c("50%","50%"),
withLoader(highchartOutput(outputId = "lineChart1", height = 500, width = 700),type = "html",loader = "dnaspin"),
withLoader(highchartOutput(outputId = "lineChart2", height = 450, width = 700),type = "html",loader = "dnaspin")
)
)
`
#实际图形的代码(在服务器中)
output$lineChart1 <- renderHighchart({
impactData <- read.csv("IMPACT_dash.csv")
colnames(impactData) <- c("Week","notAtAll","notButWill","hasSomewhat",
"hasConsiderably","hasDevastating")
highchart() %>%
hc_add_series(data = impactData, "line", color = "#404040", hcaes(x = Week, y = notAtAll),
name = "It has not and will probably never impact my life at all") %>%
hc_add_series(data = impactData, "line", color = "#8f8f8f", hcaes(x = Week, y = notButWill),
name = "It has not but will probably impact my life in the future") %>%
hc_add_series(data = impactData, color = "#91ad80", "line", hcaes(x = Week, y = hasSomewhat),
name = "It has impacted my life somewhat") %>%
hc_add_series(data = impactData, color = "#8fc96b", "line", hcaes(x = Week, y = hasConsiderably),
name = "It has impacted my life considerably") %>%
hc_add_series(data = impactData, color = "#83d64f", "line", hcaes(x = Week, y = hasDevastating),
name = "It has had a devastating impact on my life") %>%
hc_plotOptions(
series = list(
showInLegend = T,
pointFormat = "{point.y}%"
), column = list(colorByPoint = T)
) %>%
hc_yAxis(title = list(text = "Percent"),
#lables = list(format("{value}%"),
max = 100) %>%
hc_xAxis(title = list(text = "Week"), categories = impactData$Week) %>%
hc_title(text = "") %>%
hc_tooltip(pointFormat = "{point.y}%")
})
`
示例数据:
找到答案了。这是因为在我的仪表板中,我已将其设置为在打开时将页面显示为缩小 80%。这导致图表中的悬停出现问题。导致问题的代码如下