I have two graphs rendering with Rickshaw, perfectly fine. I have a single slider that I want to be able to manipulate both graphs, but what it’s doing now is manipulating the last graph that I declare:
//graph one
var graph_one = new Rickshaw.Graph( {
element: document.querySelector("#chart_one"),
height: 150,
width: 170,
renderer: 'bar',
series: data
} );
//slider code
var slider_one = new Rickshaw.Graph.RangeSlider({
element: document.querySelector('#slider-range'),
graph: graph_one
});
graph_one.render();
//graph two
var graph_two = new Rickshaw.Graph( {
element: document.querySelector("#chart_two"),
renderer: 'line',
height: 150,
width: 170,
series: data
} );
//slider code
var slider_two = new Rickshaw.Graph.RangeSlider({
element: document.querySelector('#slider-range'),
graph: graph_two
});
graph_two.render();
Is it possible to have one slider manipulate two graphs?
I accomplished this by editing the rickshaw.js, specifically editing Rickshaw.Graph.RangeSlider to accept arrays of graphs as a graph variable:
Then, when declaring the graphs, I only need to add the slider code to the last graph, including both graph variables as an array:
Works exactly how I wanted it to work: http://jsfiddle.net/bozdoz/k4NmL/