apexcharts.js icon indicating copy to clipboard operation
apexcharts.js copied to clipboard

Zoom In/Out using mouse wheel

Open Sumon-miazi opened this issue 4 years ago • 11 comments

@junedchhipa Is there any way to zoom in/out using mouse wheel? I need these features. Or how can I call apex chart build in handleZoomIn/handleZoomOut function from outside? help please...

Sumon-miazi avatar Oct 04 '19 14:10 Sumon-miazi

This would be nice, but I think it should be configurable to turn it off as well... In pages with lots of charts it might get difficult to scroll the page normally.

Thanks!

haroflow avatar Oct 25 '19 14:10 haroflow

any update on this?

elbasan avatar Dec 06 '20 23:12 elbasan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Nov 02 '21 14:11 github-actions[bot]

It's an indispensable function today. It's surprising that it's not supported

DBESSIERE avatar Jan 24 '22 18:01 DBESSIERE

I agree. This is a must have feature. Reopening.

brianlagunas avatar Jan 24 '22 18:01 brianlagunas

I would love it, is the only think I miss from apexcharts

jbiosca78 avatar Mar 10 '22 12:03 jbiosca78

Agreed here, would be useful for the timeline charts especially

OsmnShkh avatar Mar 12 '22 21:03 OsmnShkh

Thanks for reopening this feature request, I also agree it would be a very useful feature.

justinyng avatar Mar 16 '22 15:03 justinyng

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 16 '22 14:05 github-actions[bot]

Not yet?? I want this feature

gyoogle avatar Jul 05 '22 04:07 gyoogle

+1

SerhatUzbas avatar Aug 26 '22 08:08 SerhatUzbas

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 25 '22 14:10 github-actions[bot]

Please tell me if this functionality has appeared?

Sandr0oo avatar Feb 21 '23 14:02 Sandr0oo

I agree. This is a must have feature. please Reopening.

RDUser-dev avatar Feb 23 '23 15:02 RDUser-dev

  • 1

fikrihanda avatar Mar 08 '23 08:03 fikrihanda

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 07 '23 14:05 github-actions[bot]

I got tired of waiting for this, 4 years and nobody cares about a simple mouse option.. I'm moving to flotcharts

jbiosca78 avatar Jun 16 '23 12:06 jbiosca78

need this feature !!

abruu avatar Aug 08 '23 05:08 abruu

+1

mrosminin avatar Aug 16 '23 09:08 mrosminin

use this, note var chart is the chart instance after it is rendered.

document.querySelector("#your-chart").addEventListener('wheel', function(event) {
    event.preventDefault(); // Prevent scrolling the page

    // Calculate the relative position of the mouse on the chart
    var chartRect = chart.w.globals.dom.baseEl.getBoundingClientRect();
    var mouseX = (event.clientX - chartRect.left) / chartRect.width;

    var currentMinX = chart.w.globals.minX;
    var currentMaxX = chart.w.globals.maxX;
    var totalX = currentMaxX - currentMinX;

    // Determine zoom factor
    var zoomFactorIn = 0.1; // Adjust this value as needed for zooming in
    var zoomFactorOut = 0.9; // Significantly larger factor for zooming out
    var zoomRange;

    var newMinX, newMaxX;
    if (event.deltaY < 0) {
        // Zoom In
        zoomRange = zoomFactorIn * totalX;
        var midPoint = currentMinX + mouseX * totalX;
        newMinX = midPoint - zoomRange / 2;
        newMaxX = midPoint + zoomRange / 2;
    } else {
        // Zoom Out
        zoomRange = zoomFactorOut * totalX;
        newMinX = currentMinX - zoomRange / 2;
        newMaxX = currentMaxX + zoomRange / 2;
    }

    // Constrain within original chart bounds
    newMinX = Math.max(newMinX, chart.w.globals.initialMinX);
    newMaxX = Math.min(newMaxX, chart.w.globals.initialMaxX);

    // Apply zoom if valid
    if (!isNaN(newMinX) && !isNaN(newMaxX) && newMinX < newMaxX) {
        chart.zoomX(newMinX, newMaxX);
    }
});

(Thanks, ChatGPT!)

hokascha avatar Nov 20 '23 10:11 hokascha

flotcharts

You went from this to a jquery library?

+1 for this feature

tony-nz avatar Feb 12 '24 19:02 tony-nz