0

R ggplotly geom_area (area chart) tooltip issue - showing same tooltip value in all x-axis.

I am facing tooltip issue in my projects while creating area charts using geom_area from ggplot package in R (for the tooltip, converted into plotly object using ggplotly() function from plotly package). for all x-axis, it is showing same tooltip value.

Please see the reproducible example code (this code is from r graph gallery).

# Packages
library(ggplot2)
library(dplyr)
library(plotly)

# create data
time <- as.numeric(rep(seq(1,7),each=7))  # x Axis
value <- runif(49, 10, 100)               # y Axis
group <- rep(LETTERS[1:7],times=7)        # group, one shape per group
data <- data.frame(time, value, group)

# stacked area chart
ggplotly(
  ggplot(data, aes(x=time, y=value, fill=group)) + 
    geom_area()
)

Please see below images, I am getting same tooltip value all x-axis. could someone please help me to resolve this.

Area chart with tooltip 1

area chart with tooltip 1

Area chart with tooltip 2

area chart with tooltip 2

package versions: "ggplot2" - "3.4.0" "plotly" - "4.10.1"

Kat
  • 15,669
  • 3
  • 18
  • 51
Amrita
  • 1
  • 1
  • I tried it with `geom_col` and it works fine, but with `geom_area`, when hovering, only the first value of the group is shown. – markhogue May 25 '23 at 12:10
  • 1
    @markhogue, I tried with geom_col, geom_line, geom_point, there is no issues with other geoms. I think the issue is only with geom_area. I didn't have this issue before. – Amrita May 25 '23 at 13:46
  • 1
    this looks related: https://stackoverflow.com/questions/47331323/ggplotly-and-geom-area-display-informations-when-hovering-over-an-area-not-a – RyanStochastic May 25 '23 at 20:48

0 Answers0