Skip to content

filter_breaks_to_range cannot filter temporal breaks, so out-of-domain ticks survive #513

Description

@thomasp85

This issue was surfaced during the Hephaestus writer work

Summary

filter_breaks_to_range (src/plot/scale/breaks.rs:292) returns the break list unchanged unless both range endpoints are ArrayElement::Number, and inside the predicate it explicitly keeps any break that is not a Number. A Date / DateTime / Time scale therefore never gets filtered: a calendar-aligned major computed outside the resolved domain survives, and both writers place a tick off-panel.

Reproduction

VISUALISE Date AS x, Temp AS y FROM ggsql:airquality
DRAW line
SCALE x SETTING breaks => '2 months'
domain: ['1973-04-23', '1973-10-07']
values: ['1973-04-01', '1973-06-01', '1973-08-01', '1973-10-01', '1973-12-01']

1973-04-01 and 1973-12-01 are both outside the resolved domain.

Suggested fix

Filter on ArrayElement::to_f64() for the range endpoints and the breaks alike — which is exactly what the minor breaks path already does — falling back to the current pass-through only when a value has no numeric projection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions