Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6.
The bug
Rendering two
<Line>series where the second one has holes (thedataKeyis missing on someentries) produces
NaNin the generateddattribute — and not only at the hole: every point onthat axis becomes
NaN, so the whole chart disappears and the console fills with SVG errors.Why
Two separate places let a non-finite value through.
1.
lib/createSeries.ts— the axis domain is computed withMath.min/Math.maxover the raw series.accessData()returnsundefinedfor an entry that does not have the key, andMath.min(1, undefined)isNaN. So the axis registers{min: NaN, max: NaN},scaleLinearis built on a
NaNdomain increatePoints.ts, and every point it maps — including thepoints of the other, complete series sharing that axis — comes back
NaN. That is the partthat makes it look like the library cannot draw holes at all.
2.
lib/utils.ts—pointDefinedacceptsNaN.typeof NaN === 'number', so the gap-splitting logic inshapes/Curve.tsx— which is otherwisecompletely correct and already supports
connectNulls— never sees the hole, keeps the point inthe current segment, and hands
NaNstraight to d3'sline().The fix
pointDefinedchecksNumber.isFiniteinstead oftypeof, so a missing point actually startsa new segment (or is dropped under
connectNulls), which is whatCurve.tsxalready intends.createSeriesfilters non-finite values out of the values it feeds toMath.min/Math.max, andthe stacked accumulator skips them too, so one series with holes can no longer poison the axis
domain for every series on it.
No API change, no new option —
connectNullskeeps its documented meaning and now actually works.Reproducing
@stregouet's minimal repro is at https://github.com/stregouet/test-solidcharts — delete
data.value2at one index and both lines vanish onmain; with this patch the first line rendersnormally and the second draws as two segments around the gap (or one continuous line with
connectNulls).