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

Bug in 2.0.3: Error when first data point is 0, "The provided double value is non-finite" #79

Open
tsnork opened this issue Jul 28, 2023 · 1 comment
Assignees
Labels

Comments

@tsnork
Copy link

tsnork commented Jul 28, 2023

when the first value in data array is 0

let data = {
    "labels": [
        202303,
        202304,
        202305,
        202306
    ],
    "datasets": [
        {
            "data": [
                0,
                1,
                3,
                6
            ],
            "label": "Test",
            "borderColor": "#409b8c",
            "trendlineLinear": {
                "style": "#409b8c",
                "lineStyle": "dotted",
                "width": 1,
                "projection": false
            }
        }
    ]
};

the following error gets thrown:

Uncaught TypeError: Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': The provided double value is non-finite. at addFitter (chartjs-plugin-trendline.js:136:24)

Changing the first value to any int > 0 solves this issue, every other data point can be 0. Values < 0 cause this error as well.

let data = {
    "labels": [
        202303,
        202304,
        202305,
        202306
    ],
    "datasets": [
        {
            "data": [
                2
                0,
                3,
                6
            ],
            "label": "Test",
            "borderColor": "#409b8c",
            "trendlineLinear": {
                "style": "#409b8c",
                "lineStyle": "dotted",
                "width": 1,
                "projection": false
            }
        }
    ]
};

Here's a codepen with the reproducible issue:

https://codepen.io/tsnork/pen/RwqqaJg

Thx for your work with this library!

@Makanz
Copy link
Owner

Makanz commented Aug 21, 2023

I removed the "logarithmic" setting, and that made the chart start working. Now, I need to keep looking into why logarithmic scale caused this problem. @tsnork

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

No branches or pull requests

2 participants