I asked this question to the ggvis
google group, but thought I'd repost here in case anybody who didn't see that question has any ideas.
I'm trying to somewhat replicate the following chart, though I realize that the current version of ggvis may not be capable of fully replicating:
http://next.mlssoccer.com/standings/weekly
Here are some example data that form a subset of what such a chart might look like:
team1 matchno rank
1 OS 1 1
2 AX 1 3
3 OS 2 1
4 DU 1 2
5 OS 3 1
6 MP 1 2
7 AX 2 3
8 DU 2 4
9 AX 3 2
10 MP 2 2
11 DU 3 3
12 MP 3 1
13 AX 4 3
14 OS 4 1
15 DU 4 4
16 OS 5 1
17 MP 4 2
18 OS 6 1
19 DU 5 4
20 AX 5 3
21 MP 5 2
22 AX 6 3
23 MP 6 2
24 DU 6 4
Here is how far I have gotten with my interactivity:
library(ggvis)
mydf %>%
ggvis(~matchno,~rank, stroke = ~team1) %>%
layer_points(size := 50, size.hover := 200, fill = ~team1) %>%
layer_lines(stroke.hover = ~team1, strokeWidth.hover := 4, strokeWidth := 2) %>%
add_axis("x", title="Match number", subdivide = 0, values = seq(1, 6, by = 1), format="####") %>%
add_axis("y", title="Rank", subdivide = 0, values = seq(1, 4, by = 1), format='####') %>%
scale_numeric("y", reverse=TRUE)
So my questions would be:
1) is it possible to make the other lines more opaque if another line is hovered over?
2) if one hovers over a line and then move the mouse over a data point the change in line thickness/color recedes back to the original line color and thickness. Is it possible to keep the line thicker when a point on that line is hovered over?
3) Is it possible to have the points increase in size when the line is hovered over?
I'm guessing the answers to these questions might be to do with linked_brush
, but within the same plot as opposed to between two plots ?
Here are the above data graphed with the orange line hovered over and increasing thickness. This thickness goes away when you hover over an orange data point currently. Also, the other lines don't fade when a different line is hovered over.
#data:
mydf <-data.frame(
team1 = c("OS", "AX", "OS", "DU", "OS", "MP", "AX", "DU", "AX", "MP", "DU", "MP", "AX", "OS", "DU", "OS", "MP", "OS", "DU", "AX", "MP", "AX", "MP", "DU"),
matchno = c(1, 1, 2, 1, 3, 1, 2, 2, 3, 2, 3, 3, 4, 4, 4, 5, 4, 6, 5, 5, 5, 6, 6, 6),
rank = c(1, 3, 1, 2, 1, 2, 3, 4, 2, 2, 3, 1, 3, 1, 4, 1, 2, 1, 4, 3, 2, 3, 2, 4) )