I am using gvisMerge
to bring together several gvisAnnotatedTimeLine
objects. Is it possible for all the gvisAnnotatedTimeLine objects to all use the same RangeSelector, i.e. if I choose a range between two dates/times in one gvisAnnotatedTimeLine
graph, it subsequently automatically adjust the range for the other graphs that were merged together to reflect the same range?

- 13,015
- 22
- 82
- 169
-
When solving similar problem, I found [this link](http://timelyportfolio.github.io/rCharts_dygraphs/retail.html) – Daniel Krizian Mar 16 '14 at 14:40
1 Answers
i'm pretty sure the answer is no.
if gvisMerge could change parameter values for the googleVis objects passed to it, then it would need an accessor method and a mutator method (i.e., a getter and a setter), neither of which it has.
What's more, gVisMerge is purely for the placement of exactly two googleVis objects on a single HTML page (in fact formatting more than two googleVis objects at a time requires multiple recursive calls to gvisMerge).
If you look the method signature for gVisMerge:
gvisMerge(x, y, horizontal = FALSE,
tableOptions = "border=\"0\"",
chartid
)
Aside from x and y (the two googleVis objects to merge on a single HTML page), and chartid which is requires just so that the new mreged googleVis object has a unique chartid, the arguments to gvisMerge all relate to formatting or styling:
horizontal = FALSE: whether the two charts are positioned side-by-side or above-below (default)
tableOptions: pure HTML formatting (e.g., for setting a background color for the HTML page or the spacing between the two chart placed on the page via gvisMerge)
A solution not using gvisMerge:
A chart created from a googleVis constructor is an R object of class gvis and class list.
One component of a gvis object is jsDrawChart, which combines the data and the appropriate google visualization API function with the user options (parameter values to the googleVis function).
So it's the arguments passed to this function that you would want to access and modify, but you have to do this before passing the googleVis object (chart) to gvisMerge--because once you call gvisMerge then you have a new gvis object in which the original annotated timeline chart is one component.
What's more, charts created by googleVis are rendered in Flash; clearly you ought to modify the googleVis objects as early in your workflow as possible. My guess is that shouldn't be difficult because all you need to set common min & max values for the axes is the data set displayed by each chart. Therefore, just calculate a common range ex ante:
> r1 = range(d1)
> r2 = range(d2)
> r1
[1] 0.23 .75
> r2
[1] 0.11 0.46
append the returned values from a call to range for each AnnotatedTimeLine chart, then pass in this aggregated range for every call to AnnotatedTimeLine, which will obviously give each chart drawn from the constructor the same min & max values on the given axis.
r12 = append(r1, r2)

- 69,080
- 24
- 165
- 199
-
Yeh, that's what I feared the answer would be...I was just wondering if anybody had come up with a novel solution, as I think it would be reasonably useful for a few people...presumably there is nothing from a javascript point of view that gets the job done is there? – h.l.m Aug 06 '12 at 07:07
-
Is it possible to do it using the original google chart code (like here: http://code.google.com/apis/ajax/playground/?type=visualization) ? If yes, you might be able to create a custom code generator in R.. – nassimhddd Aug 06 '12 at 07:17
-
well i can offer a solution but not one through gvisMerge; I'll add this to my Answer just now. – doug Aug 06 '12 at 07:18
-
Thanks for the above suggestions, but still not sure how exactly to integrate the `r1` , `r2` and `r12` objects into the R console so that when plotting two or more gvisAnnotatedTimeLine objects, the ranges will move together, when adjusting either one of them...can you please provide a quick explicit example of how the jsDrawChart is integrated to do this? – h.l.m Aug 06 '12 at 08:50