Skip to content

[Bug]: Cannot draw multiple lines with empty point #6

Open

Description

@stregouet

Bug description

hi,
first thanks for this great project! This is a long time I try to build a chart declarative library for solidjs and you dit it!
Here is my bug: I try to build two lines on a graph but there are some hole in the second line (there is no y data for some x), but console report some errors when I try to plot these points: I get some NaN in line and path svg. Do you see any workaround?

Reproduction Link

https://github.com/stregouet/test-solidcharts

Reproduction Steps

my reproduction repo is just a npm create vite@latest with a FirstChart.tsx component. If you run npm run dev and go to localhost:5173 you will see error in browser console because of the following lines

  if (index === 3) {
    delete data.value2;
  }

Expected behavior

I expect a way to configure second line on how to handle missing point or just ignore missing point.

Additional context

No response

Activity

  1. p32929 commented on Sep 20, 2026

    @p32929

    @stregouet I dug into this — it is two separate bugs, and the second one is why the whole chart breaks instead of just the hole.

    1. lib/createSeries.ts builds the axis domain with Math.min/Math.max over the raw series:

    const min = Math.min(...data, ...stackValues)
    ...
    max = max ?? Math.max(...data)

    accessData() returns undefined for the entry where you delete data.value2, and Math.min(1, undefined) is NaN. So the axis registers {min: NaN, max: NaN}, createPoints.ts builds scaleLinear on a NaN domain, and every point it maps comes back NaN — including the points of your first line, which has no holes at all. That is why it looks like the library cannot do gaps.

    2. lib/utils.ts lets NaN through the gap check:

    const pointDefined = (point: [number, number]) =>
      typeof point[0] === 'number' && typeof point[1] === 'number'

    typeof NaN === 'number'. So the segment-splitting in shapes/Curve.tsx — which is already written correctly and already supports connectNulls — never sees the hole and hands NaN to d3's line().

    So the feature you are asking for already exists, it is just unreachable: <Line connectNulls /> (or the default segmented behaviour) is exactly what you want, and both paths are broken by the two lines above.

    I opened a PR with the fix: #8 — pointDefined uses Number.isFinite, and createSeries filters non-finite values before computing the domain. No API change.

    Unblocking yourself today (last commit on this repo is 2025-07-06, so I would not wait on a release). Patch the installed package — with pnpm:

    pnpm patch solid-charts
    

    then in the printed temp dir, in dist/index.js, change the two spots above, and pnpm patch-commit <dir>. With npm/yarn, patch-package does the same. Two lines and you are unstuck.


    Free either way — you owe me nothing for the above. If you'd rather just hand it off: I take fixed-scope jobs like this, $35 for a small fix, through Fiverr escrow so you only pay on delivery — fiverr.com/fayazbinsalam · full rates: p32929.github.io/hire

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions