Composition line charts bridge NaN gaps (pre-existing in 0.0.8)

Open
#556 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
57/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
numpy, python

Research direction

Start by comparing the composition line payload and rendering path with the native xy.pyplot exports, which preserve gaps; the issue provides a minimal reproduction and a 100,000-point decimation case. Trace how invalid samples are removed and how M4 decimation handles gaps, then inspect the relevant specification and news fragment. Done means direct lines and decimated lines preserve separate segments for invalid x or y values, including with clipping, zoom, and streaming append, while finite-data behavior and native pyplot gap behavior remain intact.

Written by the indexing model from the issue text.

Description

Composition line charts remove invalid samples and connect the surviving points across the missing interval. This invents continuity where the data should have a gap.

Classification: pre-existing bug, reproduced in published PyPI xy==0.0.8 and xy==0.0.9a1. This is not a regression introduced by the alpha and is tracked as a follow-up, not a blocker for the 0.0.9 release.

Reproduction

Install either published version in a clean environment:

uv venv --python 3.11 .venv
uv pip install --python .venv/bin/python 'xy==0.0.9a1'
.venv/bin/python repro.py

Save this as repro.py:

from pathlib import Path

import numpy as np
import xy

chart = xy.line_chart(
    xy.line(np.arange(6), [0.0, 1.0, np.nan, np.nan, 1.0, 0.0]),
    width=800,
    height=420,
)
Path("gap.html").write_text(chart.to_html())
Path("gap.svg").write_text(chart.to_svg())
Path("gap.png").write_bytes(chart.to_png(scale=1))
print(xy.__version__)
print(chart.figure().build_payload()[0]["traces"])

Open the HTML in a browser and inspect the PNG/SVG. Repeat in a separate environment with xy==0.0.8.

Actual: one continuous line connects x=1 to x=4, crossing the missing x=2 and x=3 samples. The direct payload contains six input points but only four emitted marks, without preserving the gap between the surviving points.

Expected: two observed segments, x=0→1 and x=4→5, with no connecting line between them.

This contradicts design-dossier §19: Nulls, NaN, and gaps: invalid samples must create line breaks, including after decimation, while invalid values stay out of GPU buffers.

Verified scope and evidence
Case PyPI 0.0.8 PyPI 0.0.9a1
Composition, direct line with NaN y Bridges gap Bridges gap
Composition, direct line with NaN x Bridges gap Bridges gap
Composition, 100,000-point M4-decimated line with NaN y Bridges gap Bridges gap
Equivalent native xy.pyplot SVG/PNG exports Preserve gaps Preserve gaps

For the NaN-x case, use x = np.arange(6, dtype=float); x[2:4] = np.nan and y = [0, 1, 1, 1, 1, 0].

For the decimated case:

x = np.arange(100_000, dtype=float)
y = np.ones(len(x))
y[30_000:70_000] = np.nan
chart = xy.line_chart(xy.line(x, y), width=800, height=420)

The composition SVG has one path/move in all three cases; the equivalent pyplot exports have disjoint segments. PNGs were inspected visually, and the small direct example was also confirmed in a real Chromium browser. The same problem is visible in an ordinary datetime revenue report with missing days.

Environment: Linux x86_64, CPython 3.11.15, NumPy 2.4.6, native XY core, independent PyPI installations with no editable checkout or installed-package patches. Browser confirmation used Chromium with software WebGL.

Acceptance criteria
  • Preserve gap boundaries for invalid x or y samples in direct line payloads.
  • Preserve boundaries through M4 decimation; buckets must not span missing intervals.
  • Browser, PNG, and SVG show separate observed segments without NaNs in GPU buffers.
  • Cover multiple gaps, clipping/zoom, and streaming append while preserving finite-data behavior.
  • Keep native pyplot gap behavior intact and update the relevant specification and news fragment with the fix.
Dominant language
Python
Stars
1.9k
Forks
79
Avg merge
1d 39m
Merged PRs (30d)
22

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reflex-dev/xy

All issues in reflex-dev/xy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.