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

Bugfix: span gaps over null values beyond scale limits #11984

Merged
merged 8 commits into from
Jan 3, 2025

Conversation

marisst
Copy link
Contributor

@marisst marisst commented Jan 1, 2025

Currently this configuration

{
    type: 'line',
    data: {
        labels: [0, 10, 20, 30, 40, 50],
        datasets: [{
            data: [3, null, 2, 3, null, 1.5],
            spanGaps: true,
            tension: 0.4
        }]
    },
    options: {
        scales: {
            x: {
                type: 'linear',
                min: 11,
                max: 40,
            }
        }
    }
}

produces

image

Bug: The line is not spanned over to the points [0, 3] and [50, 1.5] despite spanGaps being true. This happens when the first point beyond x min or x max limits contains a null value ([10, null] and [40, null]).

This PR contains changes in _getStartAndCountOfVisiblePoints in helpers.extras.ts fixing the error. It also contains 3 new tests in controller.line.tests.js.

Now the above configuration results in:

image

Issues fixed:

@marisst marisst changed the title Bugfix: spanGaps not spanning over null values beyond scale limits Bugfix: span gaps over null values beyond scale limits Jan 2, 2025
@etimberg etimberg merged commit 1e3d6e5 into chartjs:master Jan 3, 2025
7 checks passed
@marisst
Copy link
Contributor Author

marisst commented Jan 3, 2025

@LeeLenaleee Could we add this to version 4.4.8 too? :)

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

Successfully merging this pull request may close these issues.

4 participants