Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link zoom in different charts in echarts

Tags:

echarts

We have multiple charts with zoom. Is there a way to link all this charts so they always have the same zoom factor when the user zoom in one of the charts?

like image 470
Andreas Köberle Avatar asked Jan 23 '26 05:01

Andreas Köberle


1 Answers

When having multiple grids in the same chart is not a possibility, I use this trick to do the job:

myChart.on('datazoom', function (evt) {
    var zoom = myChart.getOption().dataZoom[0];
    myOtherChart.dispatchAction({
        type: 'dataZoom',
        dataZoomIndex: 0,
        startValue: zoom.startValue,
        endValue: zoom.endValue
    });
});

Both charts have dataZoom, in my case I hide the one in myOtherChart.

like image 139
Karel Reynaldo Avatar answered Jan 26 '26 01:01

Karel Reynaldo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!