Trying to connect the scroller of either chart so that when you scroll on one chart it also scrolls on the other.
As far as I can understand, the ‘stock’ chart available from anychart has access to the ‘setRange’ functionality – however I need to use the Box charts and cannot find an alternative
var stage = anychart.graphics.create('container');
var chart_stage = anychart.graphics.create('container-chart');
var chart_stage2 = anychart.graphics.create('container-chart-2');
var chart1 = anychart.box();
chart1.data(testdata);
chart1.container('chart1');
chart1.xScroller(true);
chart1.container(chart_stage).draw();
var chart2 = anychart.box();
chart2.data(testdata);
chart2.xScroller(true);
chart2.container('chart1');
chart2.container(chart_stage2).draw();
var scroller = anychart.standalones.scroller();
var scroller2 = anychart.standalones.scroller();
scroller.parentBounds(10, 0, 400, 60);
scroller2.parentBounds(10, 100, 400, 60);
// Set range.
scroller.setRange(0.1, 0.5);
scroller2.setRange(0.1, 0.5);
scroller.container(stage);
scroller2.container(stage);
scroller.container(stage).draw();
scroller2.draw();
function synchronizeScrollers(sourceChart, targetChart) {
sourceChart.listen('scrollerchange', function (e) {
console.log(e);
scroller.setRange(e.startRatio, e.endRatio);
chart2.setRange(e.startRatio, e.endRatio);
e.startRatio = 0;
e.endRatio = 0.1;
})
}
synchronizeScrollers(chart1, chart2);