Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom go to Infinity on any event on chart #818

Open
M-t-t-h opened this issue Jun 7, 2024 · 2 comments
Open

Zoom go to Infinity on any event on chart #818

M-t-t-h opened this issue Jun 7, 2024 · 2 comments

Comments

@M-t-t-h
Copy link

M-t-t-h commented Jun 7, 2024

Hy,

I get a unexpected zoom on any event on chart.
After analyse, the function getZoomLevel return 'Infinity'.

I tried many way to resolve it with set min/max, check datas, set X, set Y... not solutions.

here my simpliest JS :


/*********************************************************************/
/***************************** macDChart *****************************/
/*********************************************************************/
var ctx_chart = document.querySelector('#macd_chart_ADAUSD_OneHour').getContext('2d');
ctx_chart.canvas.width = 1000;
ctx_chart.canvas.height = 250;

var datas = [{x:'2024-05-05 22:00:00',y:0.000414969070996751},{x:'2024-05-05 23:00:00',y:0.00027615726125757}, ... },{x:'2024-05-06 04:00:00',y:-0.000250683582229627}];


var chart_ADAUSD_OneHour_macd = new Chart(ctx_chart, {
    type: 'line',
    data: {
        datasets: [
            {
                label: 'MACD',
                data: datas.filter(function (item) {
                    return item.y !== null;
                }), 
                borderColor: 'blue',
                backgroundColor: 'rgba(0, 0, 255, 0.2)',
                borderWidth: 0.5,
                pointRadius: 0,
                fill: false,
            }
        ]
    },
    options:
    {
   plugins:
        {
            zoom:
            {
                pan: { enabled: true, mode: 'x' },
                sync: {
                    enabled: true,
                    group: 'my-charts'
                },
                zoom: {
                    wheel: { enabled: true, modifierKey: 'ctrl' }, pinch: { enabled: true, modifierKey: 'ctrl' }, drag: { enabled: true, modifierKey: 'ctrl' }, mode: 'x',
                }
            }
        },
    },
    scales:
    {
        x: { type: 'time', distribution: 'series', time: { unit: 'day' }, },
        y: {
            type: 'linear',
            display: true, position: 'left',
            title: { display: true, text: 'Price'},
        }
    }
});

I attache you the image of the graph at load VS.
on load :
graph_at_load
after any event :
graph_after_event

Thanks in advance for your help.

@luisandIT
Copy link

luisandIT commented Oct 10, 2024

@M-t-t-h Did you find any solution for this?, I've been struggling for hours with this.

@M-t-t-h
Copy link
Author

M-t-t-h commented Oct 11, 2024

@M-t-t-h Did you find any solution for this?, I've been struggling for with this. hours with this.

Hy,
Sorry for this answer : no, i didn't found any solution (and for this time, i let this project by my side).
If you find any solution, i'm still interested, please share !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants