R-CoderDotCom / calendR

Ready to print calendars with ggplot2
https://r-coder.com/calendar-plot-r/
MIT License
252 stars 35 forks source link

Hover text #20

Open grokasper opened 1 year ago

grokasper commented 1 year ago

Is there any way to change the hover text for this? I'd like to use ggplotly if possible. As of now, I've been able to get rid of the messy auto-hover-text and have it just show the day number / color label on the hover.

Thanks!

mschilli87 commented 1 year ago

@grokasper: Would you mind sharing some code and screenshots to explain what you are trying to achieve?

grokasper commented 1 year ago
ugly hover

This first image shows the default hover text that appears when you run calendR within ggplotly.

better hover

Adding tooltip = "text" to the end of the code line, I get this hover text, which is better.

I have a database that contains dates, numeric 'intensity' values (which I use to determine the color), and categorical color values (which is how I create different events to color-code the calendar accordingly). It would be great if I could hover over a date and have it show the numeric value that lines up with the date in my database.

My code to create the plot is below:

ggplotly( calendR::calendR(year = 2022, orientation = c("landscape"), title = c("Year View"), special.days = events, special.col = c("lightblue", "lightgreen", "white", "red", "yellow"), legend.pos = "top"), tooltip = "text" ) %>% layout(height = 2000) %>% config(modeBarButtons = list(list("resetViews")))

format

Nowhere in the code is my dataset with dates / colors / numeric values referenced, so I don't know how I could access these values through the calendR plot. I'm also confused why there are different size gaps between rows and why the heights of the three rows are different.

Thank you!