How can I fix the issue of showing the same tooltip value in all x-axis for area charts using ggplotly?

123 Views Asked by At

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"

0

There are 0 best solutions below