Skip to content

Instantly share code, notes, and snippets.

@reinholdsson
Last active August 29, 2015 14:01
Show Gist options
  • Save reinholdsson/d2db7472a43c3c639665 to your computer and use it in GitHub Desktop.
Save reinholdsson/d2db7472a43c3c639665 to your computer and use it in GitHub Desktop.
library(rCharts)
.ymax <- 20
.radius <- 5
a <- Highcharts$new()
a$chart(type = "scatter")
a$series(list(
list(
name = "Grupp 1",
data = list(
list(x = 20, y = 1, name = "Axel", url = "https://www.google.se/search?q=Axel", img = "http://goo.gl/397aJ0"),
list(x = 21, y = 1, name = "Hans", url = "https://www.google.se/search?q=Hans", img = "http://goo.gl/Q4xdJW")
)
),
list(
name = "Grupp 2",
data = list(
list(x = 21, y = 1, name = "Anna", url = "https://www.google.se/search?q=Anna", img = "http://goo.gl/VOkuCx")
)
),
list(
name = "Grupp 3",
data = list(
list(x = 22, y = 1, name = "Nils", url = "https://www.google.se/search?q=Nils", img = "http://goo.gl/N6uzpt")
)
)
))
a$plotOptions(
scatter = list(
point = list(
events = list(
click = "#! function() { window.open(this.options.url); } !#")),
marker = list(
symbol = "circle",
radius = .radius
)
),
series = list(stacking = "normal")
)
a$tooltip(
useHTML = T,
formatter = "#! function() {
return '<table height=84><tr><td>'
+ '<img src=\"'
+ this.point.img
+ '\" height=80 width=60></td><td>'
+ this.point.name + '<br><br>' + this.point.x + ' år'
+ '</td></tr></table>';} !#"
)
a$xAxis(title = list(enabled = F), tickInterval = 1, lineWidth = 0, tickLength = 0)
a$yAxis(title = list(enabled = F), max = .ymax, labels = list(enabled = F), lineWidth = 0, gridLineWidth = 0)
a$legend(enabled = F)
a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment