Show Sidebar Hide Sidebar

Hover Events with JavaScript in R

How to add custom hover effects to Python charts with JavaScript.

library(plotly)

xdat <- c("Bob Dylan", "The Beatles", "David Bowie", "Randy Newman", "The Rolling Stones", "Madonna", "Frank Sinatra", "The Beach Boys", "Marvin Gaye", "Prince", "The Kinks", "Elvis Presley", "Tom Waits", "U2", "The Clash", "Johnny Cash", "Kate Bush", "The Supremes", "The Smiths", "Al Green", "Pulp", "Chuck Berry", "Elvis Costello and the Attractions", "Neil Young", "Stevie Wonder", "Ray Charles", "The Pogues", "Grace Jones", "Bill Withers", "The Who", "Paul Simon", "Roy Orbison", "Arctic Monkeys", "Bruce Springsteen", "The Police", "Rod Stewart", "Steve Earle")

ydat <- c(24, 19, 9, 8, 8, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4)

p <- plot_ly(x = xdat,  y =ydat,  name = "Number",
                    marker = list(color = "#2ca02c"),
                    type = "bar", filename="hover_example")
p
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.